我正试图通过以下代码捕获sc closed
信号。
这是我的错误
Traceback (most recent call last):
signal.signal(scrapy.signals.spider_closed,scrapy_clean_up)
TypeError: an integer is required
这是代码
import scrapy
import signal,os
def scrapy_clean_up():
print "scrapy has closed!"
signal.signal(scrapy.signals.spider_closed,scrapy_clean_up)
我错过了什么吗?
答案 0 :(得分:1)
拥有Scrapy信号处理程序的常用方法是使用dispatcher
:
from scrapy.xlib.pydispatch import dispatcher
dispatcher.connect(scrapy_clean_up, signal=scrapy.signals.spider_closed)