scrapy - 保存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
解决方案
Splash 是最常见的方法。
在您大致了解 Splash 之后,请参阅https://splash.readthedocs.io/en/stable/api.html#render-png 。
推荐阅读
- docker - 如何使用 nginx docker 容器创建一个 nginx 代理链,每个 docker 具有不同的 IP?
- vue.js - ESLint 插件需要 Vue 和 Vuetify 但我只想将它们作为对等依赖项
- java - 将数据存储在会话中而不是将数据存储在数据库中的主要优点是什么?
- lsf - 在执行主机上获取 $LSB_JOBID
- kubernetes - 在安装时操作 Helm 图表值(不是 `values.yaml`)
- c# - ef core 5 InMemory 测试
- power-virtual-agents - 如何在 Power Virtual 代理中添加自定义错误消息
- android - 加密 logback android 文件
- azure - Azure VPN 网关:维护客户端配置在多个 VPN 网关创建/删除中有效
- sql - 如何获得最大日期期间