快速背景我正在学习用Python编写代码,同时学习刮。我这里的问题是,当我运行这段代码时,控制台显示确实需要的内容被刮去了,但是当我打开.jl文档时,它是空的。作为一个初学者,我可能错过了很多东西。谢谢你的帮助,如果我错过了一个类似的职位提前道歉。你知道吗
import scrapy
class ProgxSpider(scrapy.Spider):
name = 'progx'
allowed_domains = ['random.com']
start_urls = ['https://www.random.com.html']
def parse(self, response):
locations = []
for i in response.selector.xpath('//div[@class="property-info-
location ellipsis-element-control"]/text()').extract():
locations.append(i)
print(locations)
您需要使用
yield
而不是仅仅打印locations
,这样输出才会出现在.jl文件中相关问题 更多 >
编程相关推荐