Skip to content

Instantly share code, notes, and snippets.

@Nov05
Forked from korakot/selenium.py
Created July 4, 2019 06:29
Show Gist options
  • Save Nov05/0babc45d2755921614547839aacf6b8f to your computer and use it in GitHub Desktop.
Save Nov05/0babc45d2755921614547839aacf6b8f to your computer and use it in GitHub Desktop.
Use selenium in Colab
# install chromium, its driver, and selenium
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
!pip install selenium
# set options to be headless, ..
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
# open it, go to a website, and get results
wd = webdriver.Chrome('chromedriver',options=options)
wd.get("https://www.website.com")
print(wd.page_source) # results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment