我需要重新处理以前下载的网站没有下载他们再次。你知道吗
所以我想创建多个恶心。回应没有任何让步皮屑。请求的
也许一个扩展可以做到——一个中间件也可以。最小示例:
from scrapy import signals
from scrapy.http import Response
class ReprocessSnapshotsOnSpiderOpenExtension(object):
def __init__(self, crawler):
self.crawler = crawler
crawler.signals.connect(self.send_the_existing_snapshots_as_new_response, signal=signals.spider_opened)
@classmethod
def from_crawler(cls, crawler):
return cls(crawler)
def send_the_existing_snapshots_as_new_response(self, spider):
print("##### now in ReprocessSnapshotsOnSpiderOpenExtension.send_the_existing_snapshots_as_new_responses()")
response1 = Response("http://the_url_of_resp1", body=b"the body of resp1")
response2 = Response("http://the_url_of_resp2", body=b"the body of resp2")
# ....
responseN = Response("http://the_url_of_respN", body=b"the body of respN")
inject_response_somehow(response1)
inject_response_somehow(response2)
# ...
inject_response_somehow(responseN)
所以问题是:如何实现inject_response_somehow(...)
?你知道吗
有没有可能控制响应被注入的位置(在下载程序中间件/spider中间件之前/中间某处/之后)?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐