Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

scrapy selenium screnshot

#coding=utf-8
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

def test_fullpage_screenshot(self):
    chrome_options = Options()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--start-maximized')
    driver = webdriver.Chrome(chrome_options=chrome_options)
    driver.get("yoururlxxx")
    time.sleep(2)

    #the element with longest height on page
    ele=driver.find_element("xpath", '//div[@class="react-grid-layout layout"]')
    total_height = ele.size["height"]+1000

    driver.set_window_size(1920, total_height)      #the trick
    time.sleep(2)
    driver.save_screenshot("screenshot1.png")
    driver.quit()

if __name__ == "__main__":
    test_fullpage_screenshot()
Comment

PREVIOUS NEXT
Code Example
Python :: array creation method in numpy 
Python :: python enumerate unique values 
Python :: Get a list of categories of categorical variable (Python Pandas) 
Python :: R sample() funciton in python 
Python :: how to take out every even number from a list in python 
Python :: compare multiple columns in pandas 
Python :: join lists python 
Python :: concatenation array 
Python :: django template render dict 
Python :: save pillow image to database django 
Python :: streamlit sidebar width 
Python :: how to join tables in python 
Python :: username python system 
Python :: assertionerror-accepted-renderer-not-set-on-response-in-django 
Python :: r char to numeric dataframe all columns 
Python :: print list in one line python 
Python :: initialize np array 
Python :: python get line of exception 
Python :: how to drop duplicate columns in pandas that dont have the same name? 
Python :: wifite subsystem 
Python :: python multiple conditions in dataframe column values 
Python :: comtypes python 
Python :: how to remove role from people with a reaction discord bot python 
Python :: python solve linear equation system 
Python :: edit models in django admin 
Python :: python multiply string 
Python :: statsmodels 
Python :: python argparser flags 
Python :: EOFError: EOF when reading a line 
Python :: how to improve accuracy of random forest classifier 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =