Horje
python selenium web scraping example Code Example
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)




Python

Related
add colorbar to figure matplotlib line plots Code Example add colorbar to figure matplotlib line plots Code Example
python turtle background image Code Example python turtle background image Code Example
dataframe memory usage Code Example dataframe memory usage Code Example
python wait for x seconds Code Example python wait for x seconds Code Example
how to make html files open in chrome using python Code Example how to make html files open in chrome using python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9