Skip to content

Instantly share code, notes, and snippets.

@thanakijwanavit
Forked from korakot/selenium.py
Last active April 21, 2020 04:41
Show Gist options
  • Save thanakijwanavit/7999cb8ecf6e9288b8ef4cd58c090d79 to your computer and use it in GitHub Desktop.
Save thanakijwanavit/7999cb8ecf6e9288b8ef4cd58c090d79 to your computer and use it in GitHub Desktop.
Use selenium in Colab
# install chromium, its driver, and selenium
!apt install chromium-chromedriver
!pip install selenium
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
import sys
sys.path.insert(0,'/usr/lib/chromium-browser/chromedriver')
# 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
# divs = wd.find_elements_by_css_selector('div')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment