python爬虫:scrapy自定义item
2021-01-27 16:16
标签:news elf lin highlight text ike rap for 自定义item items.py 爬虫.py item和字典类似,数据量大时,字典可能键值对错误 python爬虫:scrapy自定义item 标签:news elf lin highlight text ike rap for 自定义item 原文地址:https://www.cnblogs.com/hightech/p/12844630.htmlclass LianhezaobaospyderItem(scrapy.Item):
# define the fields for your item here like:
# name = scrapy.Field()
# pass
body=scrapy.Field()
link=scrapy.Field()
from .. import items
def parse_news(self,response):
item=items.LianhezaobaospyderItem()
item[‘body‘]=response.xpath("//div[@class=‘xx‘]/text()").get()
item[‘link‘]=response.url
yield item
文章标题:python爬虫:scrapy自定义item
文章链接:http://soscw.com/index.php/essay/47831.html