Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- from selenium.webdriver.common.keys import Keys
- from selenium.webdriver.support import expected_conditions as EC
- from selenium.webdriver.support.wait import WebDriverWait
- PATH = "C:\Program Files\chromedriver.exe"
- driver = webdriver.Chrome(PATH)
- driver.get("https://www.techwithtim.net")
- # print(driver.title)
- # search = driver.find_element(By.NAME,"s")
- # search.send_keys('test')
- # search.send_keys(Keys.RETURN)
- # try:
- # main = WebDriverWait(driver, 10).until(
- # EC.presence_of_element_located((By.ID, "main"))
- # )
- # articles = main.find_elements(By.TAG_NAME,"article")
- # for article in articles:
- # header = article.find_element(By.CLASS_NAME,"entry-summary")
- # print(header.text)
- # finally:
- # driver.quit()
- link = driver.find_element(By.LINK_TEXT,"Python Programming")
- link.click()
- try:
- element = WebDriverWait(driver, 10).until(
- EC.presence_of_element_located((By.LINK_TEXT, "Beginner Python Tutorials"))
- )
- element.click()
- element = WebDriverWait(driver, 10).until(
- EC.presence_of_element_located((By.ID, "sow-button-19310003"))
- )
- element.click()
- driver.back()
- driver.back()
- driver.back()
- except:
- driver.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement