首页 > 解决方案 > 保存scrapy响应的屏幕截图

问题描述

有没有办法保存页面的Scrapy响应截图,即

scrapy shell "https://google.com" 
view(response) 

我知道我可以将输出保存为 HTML 并稍后查看,但是有没有办法将输出保存为图像?

我检查了这个问题Scrapy Splash Screenshots? , (最相关的)但我得到

png_bytes = base64.b64decode(response.data['png'])
Traceback (most recent call last):
  File "/usr/lib/python3.6/code.py", line 91, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
AttributeError: 'HtmlResponse' object has no attribute 'data'

我认为这个错误是因为在他使用的问题中Splash Request,在我的情况下是正常的Request

标签: scrapy

解决方案


Splash 是最常见的方法。

在您大致了解 Splash 之后,请参阅https://splash.readthedocs.io/en/stable/api.html#render-png 。


推荐阅读