Google Search Using Python | Search on Google using Python | Automatic Google Search Python






from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

#-------->You can use Chrome as your choice.
driver = webdriver.Firefox()
# driver = webdriver.Firefox(executable_path("path_of_Firefox_where_
it_is_stored")) # For windows user

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

#-------->Here we are putting XPATH of google search box.
google_search_box = driver.find_element_by_xpath("/html/body/div/div
[2]/form/div[2]/div[1]/div[1]/div/div[2]/input")

time.sleep(4)

#-------->Here We are passing the elements that we want to search.
google_search_box.send_keys("India")

#-------->Here we are putting XPATH of Google Search Button.

click_button = driver.find_element_by_xpath("/html/body/div/div[2]/
form/div[2]/div[1]/div[3]/center/input[1]")
click_button.click()

Comments