scrape website using selenium python code example
Example 1: python selenium web scraping example
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
PATH_TO_DRIVER = './chromedriver'
driver = webdriver.Chrome(executable_path=PATH_TO_DRIVER)
driver.get('https://google.com')
element = driver.find_element_by_name('q')
element.send_keys('Why is python so awesome')
element.send_keys(Keys.ENTER)
Example 2: scrape website with login python selenium
driver.get("https://news.ycombinator.com/login")
login = driver.find_element_by_xpath("//input").send_keys(USERNAME)
password = driver.find_element_by_xpath("//input[@type='password']").send_keys(PASSWORD)
submit = driver.find_element_by_xpath("//input[@value='login']").click()