在指定信号上注册操作
from scrapy import signals class MyExtend: def __init__(self,crawler): self.crawler = crawler # 钩子上挂障碍物 # 在指定信号上注册操作 crawler.signals.connect(self.start, signals.engine_started) crawler.signals.connect(self.close, signals.spider_closed) @classmethod def from_crawler(cls, crawler): return cls(crawler) def start(self): print(‘signals.engine_started.start‘) def close(self): print(‘signals.spider_closed.close‘)
extensions.py
原文地址:https://www.cnblogs.com/jintian/p/11438485.html
时间: 2024-10-27 11:40:13