I am learning selenium(with Python) and I was trying to make it like I would search for something on google and then save all the links that contain the word "Watches"(or any other thing that I am searching) but I don't think selenium offers that feature
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
product = "watch"
driver.get("https://www.google.com/")
try:
search = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.NAME,"q"))
)
search.clear()
search.send_keys(product)
search.send_keys(Keys.ENTER)
watches = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.LINK_TEXT,"Watches"))
)
print(watches.text)
except:
driver.quit()
print("failed to load")
time.sleep(2)
driver.quit()
this is the code I wrote can somebody find a way to do it? Thanks