我得到的twisted.internet.error.ReactorNotRestartable错误,当我执行下面的代码:
from time import sleep
from scrapy import signals
from scrapy.crawler import CrawlerProcess
from scrapy.utils.project import get_project_settings
from scrapy.xlib.pydispatch import dispatcher
result = None
def set_result(item):
result = item
while True:
process = CrawlerProcess(get_project_settings())
dispatcher.connect(set_result, signals.item_scraped)
process.crawl('my_spider')
process.start()
if result:
break
sleep(3)
第一次起作用,然后出现错误。我process每次都创建变量,这是什么问题?
森栏
弑天下
相关分类