Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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)
Comment

PREVIOUS NEXT
Code Example
Python :: open file python 
Python :: program arguments python 
Python :: count rows with nan pandas 
Python :: django and operator 
Python :: dir template 
Python :: django file upload this field is required 
Python :: How to get the value of an Entry widget in Tkinter? 
Python :: reverse text python 
Python :: cut part of video ffmpeg 
Python :: python size of linked list 
Python :: save plotly figure as png python 
Python :: smtplib not sending email 
Python :: measure execution time in ipython notebook 
Python :: pandas reset index without adding column 
Python :: reverse geocoding python 
Python :: python longest word in string 
Python :: Python program to get the file size of a plain file. 
Python :: python remove multiple characters from string 
Python :: block window if another window is open tkinter 
Python :: datetime.datetime.fromtimestamp() 
Python :: how to find total no of nan values in pandas 
Python :: relu function python 
Python :: python remove empty list 
Python :: remove a file or dir in linux or mac or ubuntu 
Python :: sqlite3 delete row python 
Python :: pandas add list to dataframe as column 
Python :: python input function 
Python :: create or update django models 
Python :: multipart/form data multipart encoder python 
Python :: pi python 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =