使用scrapy框架抓取css值 [英] scraping css values using scrapy framework

查看:60
本文介绍了使用scrapy框架抓取css值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在使用 python scrapy 框架或使用 php 抓取时抓取 css 值.任何帮助都会得到认可

Is there a way to scrap css values while scraping using python scrapy framework or by using php scraping. any help will be appreaciated

推荐答案

是的,请查看 选择器 基本上你有两种方法 response.xpath() 用于 xpathresponse.css() 用于 css 选择器.例如,要获取标题的文本,您可以执行以下任一操作:

Yes, please check the documentation for selectors basically you've two methods response.xpath() for xpath and response.css() for css selectors. For example, to get a title's text you could do any of the following:

response.xpath('//title/text()').extract_first()
response.css('title::text').extract_first()

这篇关于使用scrapy框架抓取css值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆