webkit2png.py - 滚动条始终可见
我正在使用 webkit2png.py 脚本在无头 Linux 服务器上截取一些屏幕截图。我遇到了一个超级烦人的问题,屏幕截图总是包含垂直滚动条。
我对Python或Qt不太熟悉,但从我在代码中看到的,滚动条应该始终被禁用:
从第201行开始:
self._page.mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
self._page.mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
self._page.settings().setUserStyleSheetUrl(QUrl("data:text/css,html,body{overflow-y:hidden !important;}"))
我发现有点难以理解X大小之间的关系创建的帧缓冲区(通过 -x 选项)、虚拟浏览器窗口的“几何形状”(-g)和 -W(抓取整个窗口而不是框架)选项。我尝试了很多这些数字的组合,但没有成功。我认为这可能与我的问题有关,尽管上面的代码片段会让我相信永远不应该显示滚动条。
以下是我用来截取 Facebook 登录页面屏幕截图的选项字符串:
webkit2png.py -g 1200 900 -x 1200 900 --aspect-ratio=ignore --scale=200 150 -o test.png http://www.facebook.com/
该命令的输出会生成带有垂直滚动条的屏幕截图,但我不希望出现这种情况。
有人能为我解释一下吗?
I'm using the webkit2png.py script to take some screenshots on a headless Linux server. I'm running into a super annoying issue where the screenshots always have a vertical scrollbar included.
I'm not too familiar with Python or Qt, but from what I can see in the code, scrollbars should always be disabled:
Starting at line 201:
self._page.mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
self._page.mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
self._page.settings().setUserStyleSheetUrl(QUrl("data:text/css,html,body{overflow-y:hidden !important;}"))
I'm finding it a bit hard to understand the relationship between the size of the X framebuffer created (via the -x option), the "geometry" of the virtual browser window (-g) and the -W (grab full window instead of frame) option. I've tried lots of combinations of these numbers with no success. I think this may have something to do with my problem, although the above code snippet would lead me to believe that scrollbars should NEVER be displayed.
Here's the string of options that I'm using to take a screenshot of say, Facebook's login page:
webkit2png.py -g 1200 900 -x 1200 900 --aspect-ratio=ignore --scale=200 150 -o test.png http://www.facebook.com/
The output of this command produces a screenshot with a vertical scrollbar, which I don't want.
Can anyone shed some light on this for me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,这实际上是 Facebook 通过 CSS 放入滚动条:/
Turns out this was actually Facebook putting scrollbars in via CSS :/