chronovirus
chronovirus

Reputation: 41

How to search on Google with Selenium in Python?

I'm really new to web scraping. Is there anyone that could tell me how to search on google.com with Selenium in Python?

Upvotes: 1

Views: 217

Answers (3)

Sushil
Sushil

Reputation: 5531

In order to search something on google, try this:

from selenium import webdriver

driver = webdriver.Chrome()

driver.get('https://www.google.com/')

textbox = driver.find_element_by_xpath('//input[@name=\"q\"]')

textbox.send_keys('who invented python\n')

Upvotes: 1

John Donn
John Donn

Reputation: 1858

Don't use Selenium, there are other tools more suitable for that. Be aware that Google does not look upon favorably on scraping their search results:

Google does not take legal action against scraping, likely for self-protective reasons. However, Google is using a range of defensive methods that makes scraping their results a challenging task.

Source: https://en.wikipedia.org/wiki/Search_engine_scraping

Upvotes: 1

Parker Anderson
Parker Anderson

Reputation: 33

Selenium probably isn't the best. other libraries/tools would work better. BeautifulSoup is the first one that comes to mind

Upvotes: 1

Related Questions