Take a full page screenshot with Firefox on the command-line

后端 未结 6 1540
梦如初夏
梦如初夏 2020-12-04 04:34

I\'m running Firefox on a Xvfb in a VPS. What I want to do is to take a full page screenshot of the page.

I can redirect Firefox to particular page using

<         


        
6条回答
  •  天命终不由人
    2020-12-04 05:14

    You can use selenium and the webdriver for Firefox.

    import selenium.webdriver
    import selenium.common
    
    options = selenium.webdriver.firefox.options.Options()
    # options.headless = True
    with selenium.webdriver.Firefox(options=options) as driver:
        driver.get('http://google.com')
        time.sleep(2)
        root=driver.find_element_by_tag_name('html')
        root.screenshot('whole page screenshot.png')
    

提交回复
热议问题