码迷,mamicode.com
首页 > Web开发 > 详细

selenium实现网页截全屏

时间:2019-11-22 12:12:44      阅读:379      评论:0      收藏:0      [点我收藏+]

标签:fetch   scree   cut   less   cer   scroll   webdriver   errors   rip   

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--dns-prefetch-disable')
options.add_argument('--no-referrers')
options.add_argument('--disable-gpu')
options.add_argument('--disable-audio')
options.add_argument('--no-sandbox')
options.add_argument('--ignore-certificate-errors')
options.add_argument('--allow-insecure-localhost')

driver = webdriver.Chrome(options=options)
driver.get('http://www.douban.com')
width = driver.execute_script(
        "return Math.max(document.body.scrollWidth, document.body.offsetWidth, document.documentElement.clientWidth, document.documentElement.scrollWidth, document.documentElement.offsetWidth);")
height = driver.execute_script(
        "return Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);")
driver.set_window_size(width + 100, height + 100)
driver.save_screenshot('douban.png')
driver.close()

selenium实现网页截全屏

标签:fetch   scree   cut   less   cer   scroll   webdriver   errors   rip   

原文地址:https://www.cnblogs.com/ldy-miss/p/11910630.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!