Python编程学习利用Scrapy获取链家房源数据
发布时间
阅读量:
阅读量
采集链家租房网站首页的房源数据,所提取的信息涵盖:房源名称、租金金额以及对应的网页链接
import scrapy
class ScrapytestItem(scrapy.Item):
# define the fields for your item here like:
title = scrapy.Field()
price = scrapy.Field()
url = scrapy.Field()
AI写代码python
运行
import json
class ScrapytestPipeline(object):
#打开文件
def open_spider(self,spider):
self.file = open('58_chuzu.txt','w',encoding='utf-8')
print('文件被打开了')
#写入文件
全部评论 (0)
还没有任何评论哟~
