screenshot - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: screenshot (/thread-25768.html) |
screenshot - arezoo - Apr-11-2020 I want to take picture from page in different size(picture must be responsive) i do not want use api. the api that there is in this site(https://www.site-shot.com/) is good ,and i want to use code that work same. RE: screenshot - buran - Apr-11-2020 And your question is? You want to write code that do the same? You want to use their API? Something else? What have you tried so far? Post your code in python tags, full traceback - if you get one - in error tags. RE: screenshot - arezoo - Apr-11-2020 yes,i want to write code to take picture from page in define size.(mobile size and desktop size) from selenium import webdriver from selenium.webdriver.chrome.options import Options import time # Provide a list of urls to create screenshots from link = 'http://digikala.com' # The Chrome and ChromeDriver Paths will vary based on your Operating System. # This example shows how to configure ChromeDriver for Mac CHROME_PATH = '/usr/bin/google-chrome-stable' CHROMEDRIVER_PATH = '/home/arezoo/Desktop/chromedriver' # Set the Browser Size WINDOW_SIZE = "320,480" # Configure Chrome Options chrome_options = Options() chrome_options.add_argument("--headless") chrome_options.add_argument("--window-size=%s" % WINDOW_SIZE) chrome_options.binary_location = CHROME_PATH driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, options=chrome_options) # Loop through the list of urls and save the screenshot driver.get(link) # sleep for 2 seconds to allow the page to fully load. time.sleep(2) # create a clean filename from the url str = link.split('://')[1] filename = str.replace('/', '__') image = filename.replace('.', '_') + ".png" # save the screenshot driver.save_screenshot(image) # Close Selenium driver.close() RE: screenshot - buran - Apr-11-2020 If you continue like this, it will be very difficult to get real help. What is the problem with that code? Describe your specific problem and ask specific questions... |