标签:import none span @class 打开 single mys spi pid
1、类
from scrapy import signals class MySingle(object): def __init__(self): pass @classmethod def from_crawler(cls, crawler): self = cls() crawler.signals.connect(self.spider_open, signal=signals.spider_opened) crawler.signals.connect(self.spider_close, signal=signals.spider_closed) return self def spider_open(self, spider): print(‘打开‘) def spider_close(self, spider): print(‘关闭‘)
2、配置文件
EXTENSIONS = { # ‘scrapy.extensions.telnet.TelnetConsole‘: None, ‘toscrapy.mysingles.MySingle‘: 555, }
标签:import none span @class 打开 single mys spi pid
原文地址:https://www.cnblogs.com/wt7018/p/11756296.html