码迷,mamicode.com
首页 > Web开发 > 详细

scrapy xpath / css

时间:2019-07-31 21:37:10      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:res   scrapy   技术   @class   color   strip()   time   rip   ace   

技术图片

 

title = response.xpath(//h2[@class="margin-top-0"]/a/text())
read_num = response.xpath(//div[@class="col-md-12"]/p[@class="text-muted"]/small/text()).extract()[3].strip().replace(阅读(, ‘‘).replace(), ‘‘)
commen_num = response.xpath(//div[@class="col-md-12"]/p[@class="text-muted"]/small/text()).extract()[4].strip().replace(评论(, ‘‘).replace(), ‘‘)
add_time = response.xpath(//div[@class="col-md-12"]/p[@class="text-muted"]/small/text()).extract()[5].strip()
content = response.xpath(//div[@class="content"]//*).extract()[0]
tag_list = response.xpath(//a[@class="text-muted"]/text()).extract()
tag_str = $$.join(tag_list)

技术图片

title = response.css(".margin-top-0 a::text").get()
read_num = response.css("p.text-muted small::text").getall()[3].strip().replace(阅读(, ‘‘).replace(), ‘‘)
commen_num = response.css("p.text-muted small::text").getall()[4].strip().replace(评论(, ‘‘).replace(), ‘‘)
add_time = response.css("p.text-muted small::text").getall()[5].strip()
content = response.css(".content *").getall()
tag_list = response.css("a.text-muted::text").getall()
tag_str = $$.join(tag_list)

 

scrapy xpath / css

标签:res   scrapy   技术   @class   color   strip()   time   rip   ace   

原文地址:https://www.cnblogs.com/phper8/p/11278965.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!