from selenium import webdriver
import time
# open firefox
browser = webdriver.Firefox()
browser.get("https://www.google.com.tr/")
time.sleep(1)
# search input field
search = browser.find_element_by_xpath("//*[@id='tsf']/div[2]/div/div[1]/div/div[1]/input")
search.send_keys("javascript")
time.sleep(1)
# search button
search_button = browser.find_element_by_xpath("//*[@id='tsf']/div[2]/div/div[2]/div[2]/div[2]/center/input[1]")
search_button.submit()
time.sleep(3)
# scroll
scrollCounter = 0
while scrollCounter <= 5:
browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")
scrollCounter += 1
time.sleep(1)
# close firefox
browser.close()
Leave a comment