如何直接访问Scrapy httpcache中间件数据

时间:2013-03-19 18:25:13

标签: scrapy

我如何直接从scrapy访问httpcache中间件?

伪代码中的类似内容

URL = 'http://scrapedsite.com/category1/item1'
print retrieveRawHtml(URL)

1 个答案:

答案 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)

如果启用了缓存,它将从缓存中拉出。