如何使用 python-webkit2png 同时截取多个屏幕截图?
我有来自许多主机的数千个网址需要截图。
我可以从命令行很好地使用该库,但如何将其集成到我的代码中,以便我可以同时截取多个屏幕截图?
我认为这与 xvfb 有关,就像这个问题的答案一样:
I've got thousands of urls from many hosts I need to screenshot.
I can use the lib fine from the command line, but how can I integrate it into my code so I can take multiple screenshots simultaneously?
I think it's something to do with xvfb as with the answer to this question: How to kill headless X server started via Python? but I'm not sure what exactly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里我使用了一个参数来传递 .txt 的位置,其中包含站点列表(换行符分隔),第二个参数用于传递输出 PNG 文件的位置。
https://gist.github.com/deadstar1/e8d30102afbaefec531d6708f761e104
感谢@paljenczy
here I have used an argument to pass a location of .txt, which contains a list of site(newline delimited), and the second argument for the location of output PNG file.
https://gist.github.com/deadstar1/e8d30102afbaefec531d6708f761e104
thanks to @paljenczy
我使用
subprocess
调用webkit2png
(它是通过python-webkit2png
安装的),效果很好。
I used
subprocess
to callwebkit2png
(which was installed throughpython-webkit2png
),it worked fine.
可能是这样的(未经测试):
这是无耻地从 源中窃取的webkit2png.py的代码。
Probably something like this (untested):
This was shamelessly ripped off from the source code of webkit2png.py.