zoukankan      html  css  js  c++  java
  • selenium实现网页截全屏

    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()
    
  • 相关阅读:
    Java类加载器总结
    Java程序编译和运行的过程
    Spring+Struts2+Hibernate整合
    Spring+MyBatis+SpringMVC整合
    声明式事务管理
    Scala sbt 添加国内镜像
    持续天数算法
    idea run shell set user name
    java insert mysql 中文乱码
    Samba服务器 安装
  • 原文地址:https://www.cnblogs.com/ldy-miss/p/11910630.html
Copyright © 2011-2022 走看看