Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from selenium import webdriver
- from selenium.webdriver.chrome.service import Service
- import time
- def initializeDriver():
- ### Initialise Driver for all search engines here !!
- options = webdriver.ChromeOptions()
- options.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"])
- options.add_experimental_option("useAutomationExtension", True)
- options.add_argument('--disable-gpu')
- # to hide the browser
- # options.add_argument('--headless')
- service = Service('chromedriver.exe')
- return webdriver.Chrome(service=service, options=options)
- driver = initializeDriver()
- driver.get("https://www.google.com")
- time.sleep(1)
- # change language to English
- driver.find_element("css selector", value = "#SIvCob > a").click()
- # find element by CSS selector
- searchTextBox = driver.find_element( "css selector", value = "#APjFqb")
- searchTextBox.send_keys("Prayer Times in Gaza")
- # press enter
- searchTextBox.submit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement