I have been using Selenium in Google Colab to do some scrapping for some time now. I use:
# install chromium, its driver, and selenium
!apt update
!apt install chromium-chromedriver
!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
And until today it worked perfectly, but today I ran this code and it started giving this error:
ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py)
I have tried manually installing typing.py, I've tried updating the python version, but nothing has worked. Can some one please help me to run Selenium (with Chrome) in Google Colab?
I've noticed that the same error happens in all answers I have found about this topic such as:
How to use Selenium on Colaboratory Google?
https://gist.github.com/korakot/5c8e21a5af63966d80a676af0ce15067