Advertisement

Python Project With Source Code - Snapshot of given website

Python Project With Source Code - Snapshot of given website

Snapshot of given website

## Set up

`pip install selenium`

`pip install chromedriver-binary==XX.X.XXXX.XX.X`

- 'XX.X.XXXX.XX.X' is chrome driver version.

- The version of 'chrome driver' need to match the version of your google

chrome.

*How to find your google chrome version*

1. Click on the Menu icon in the upper right corner of the screen.

2. Click on Help, and then About Google Chrome.

3. Your Chrome browser version number can be found here.

## Execute

`python snapshot_of_given_website.py <url>`

Snapshot is in current directory after this script runs.

Requirement:

selenium==3.141.0

chromedriver-binary==85.0.4183.38.0

Source Code:

# -*- cofing: utf-8 -*-

import sys

from selenium import webdriver

from selenium.webdriver.chrome.options import Options

import chromedriver_binary

script_name = sys.argv[0]

options = Options()

options.add_argument('--headless')

driver = webdriver.Chrome(options=options)

try:

url = sys.argv[1]

driver.get(url)

page_width = driver.execute_script('return document.body.scrollWidth')

page_height = driver.execute_script('return document.body.scrollHeight')

driver.set_window_size(page_width, page_height)

driver.save_screenshot('screenshot.png')

driver.quit()

print("SUCCESS")

except IndexError:

print('Usage: %s URL' % script_name)

Post a Comment

0 Comments