Skip to content

Instantly share code, notes, and snippets.

@kargaranamir
Last active August 25, 2023 20:13
Show Gist options
  • Save kargaranamir/ef2e6c25d8c221f5aa454c63946add0a to your computer and use it in GitHub Desktop.
Save kargaranamir/ef2e6c25d8c221f5aa454c63946add0a to your computer and use it in GitHub Desktop.
install selenium in google colab
# install chromium and selenium
!apt update
!apt install chromium-chromedriver
!pip install selenium
from selenium import webdriver
from selenium.common.exceptions import WebDriverException

options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')

# Initialize WebDriver and get the HTML file
wd = webdriver.Chrome(options=options)
wd.set_window_size(1366, 728)
wd.get('https://kargaranamir.github.io')


# Wait for some time to ensure page is fully loaded (adjust as needed)
wd.implicitly_wait(10)

# Take screenshot of the visible area and save it
screenshot_path = 'screenshot.png'
wd.save_screenshot(screenshot_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment