我如何直接从scrapy访问httpcache中间件?
伪代码中的类似内容
URL = 'http://scrapedsite.com/category1/item1'
print retrieveRawHtml(URL)
答案 0 :(得分:2)
from scrapy.utils.response import open_in_browser
from scrapy.http import HtmlResponse
url = 'http://scrapedsite.com/category1/item1'
body = '<html>hello</html>'
response = HtmlResponse(url, body=body)
open_in_browser(response)
或来自你的回调:
def parse_cb(self, response):
from scrapy.utils.response import open_in_browser
open_in_browser(response)
如果启用了缓存,它将从缓存中拉出。