Answers for "scrape website using selenium python"

1

python selenium web scraping example

#Python example - use chrome driver to open google url and enter into search bar "Why is python so awesome"

#required imports
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

#open driver
PATH_TO_DRIVER = './chromedriver'
driver = webdriver.Chrome(executable_path=PATH_TO_DRIVER)

#launch url using driver
driver.get('https://google.com')

#find element to manipulate e.g. by element name. 'q' is the element name of the google search bar
element = driver.find_element_by_name('q')

#write text into search bar
element.send_keys('Why is python so awesome')

#simulates 'Enter' key
element.send_keys(Keys.ENTER)
Posted by: Guest on August-23-2020
0

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()
Posted by: Guest on October-01-2020

Code answers related to "scrape website using selenium python"

Python Answers by Framework

Browse Popular Code Answers by Language