CoCalc Public Fileschrome-webdriver.ipynbOpen with one click!
Author: Harald Schilly
Views : 65

Chrome Selenium Webscraping on CoCalc

In [1]:
from selenium import webdriver from selenium.webdriver.common.keys import Keys from IPython.display import Image import json import time
In [2]:
options = webdriver.ChromeOptions() options.add_argument('--no-sandbox') options.add_argument('--window-size=1420,1080') options.add_argument('--headless') options.add_argument('--disable-gpu') user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36" options.add_argument(f'user-agent={user_agent}') driver = webdriver.Chrome(options=options) driver.implicitly_wait(10)
In [3]:
url = "https://otter.ai/login" driver.get(url)
In [4]:
test = driver.find_element_by_xpath('/html/body/div[1]/div/nav') test.text
'Otter.ai\nProduct\nResources\nCompany\nLog in\nSign up'
In [5]:
Image(data=test.screenshot_as_png)
In [ ]:
In [ ]: