【发布时间】:2018-01-12 18:36:32
【问题描述】:
您好,我正在尝试从 scrapy 构建一个简单的爬虫。
代码在 scrapy shell 中运行良好,但是当我通过控制台运行它时,它不会向 json 文件写入任何内容。
我从项目顶层目录运行它
scrapy crawl filemare -o filemare.json
import scrapy
class FilemareSpider(scrapy.Spider):
name = "filemare"
allowed_domains = ['https://filemare.com/']
start_urls = ["https://filemare.com/en-
us/search/firmware%20download/632913359"]
def parse(self, response):
items = response.xpath('//div[@class="f"]/text()').extract()
#items = response.css('div.f::text').extract()
for url in items:
print(url)
yield url
【问题讨论】:
标签: python scrapy web-crawler