这可能是在Scrapy Python中传递参数到process.crawl的子问题,但作者将回答(不回答我自己提出的子问题)标记为满意的答案。
我的问题是:我无法使用
这是代码:
我的问题是:我无法使用
scrapy crawl mySpider -a start_urls(myUrl) -o myData.json
,而是想/需要使用crawlerProcess.crawl(spider)
。我已经找到了几种传递参数的方法(无论如何,在我链接的问题中都有答案),但我不知道该如何告诉它将数据转储到myData.json中...即-o myData.json
部分。 有人有建议吗?或者我只是没有理解它应该如何工作..?这是代码:
crawlerProcess = CrawlerProcess(settings)
crawlerProcess.install()
crawlerProcess.configure()
spider = challenges(start_urls=["http://www.myUrl.html"])
crawlerProcess.crawl(spider)
#For now i am just trying to get that bit of code to work but obviously it will become a loop later.
dispatcher.connect(handleSpiderIdle, signals.spider_idle)
log.start()
print "Starting crawler."
crawlerProcess.start()
print "Crawler stopped."
"FEEDS": { "items.json": {"format": "json"}, }
来源:https://docs.scrapy.org/en/latest/topics/practices.html?highlight=run%20from%20script#run-scrapy-from-a-script - undefined