我如何从Facebook页面获取完整帖子的屏幕截图
在此处输入映像说明当我从Facebook页面进行每个帖子的屏幕截图时,我只会得到一个部分缩放后的帖子。
代码:
post = browser.find_element_by_xpath("class")
browser.execute_script("document.body.style.zoom='80%'")
screen = post.screenshot_as_png
im = Image.open(BytesIO(screen))
im.save('image.png')
enter image description herewhen i did the screenshot of each post from Facebook page i get just a part from post after zoom out.
code:
post = browser.find_element_by_xpath("class")
browser.execute_script("document.body.style.zoom='80%'")
screen = post.screenshot_as_png
im = Image.open(BytesIO(screen))
im.save('image.png')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
XPath的屏幕截图:
Selenium没有尝试将页面格式化以进行屏幕截图,而是可以通过XPath捕获屏幕截图 。请参阅以下代码:
Screenshot by XPATH:
Instead of trying to format the page to take a screenshot, Selenium has a way to capture a screenshot by the XPATH. See the below code:
solutuion
我确定您可以更改它
python
Solutuion
I am sure you can change it
python