Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
693 views
in Technique[技术] by (71.8m points)

text in search results with selenium and python

can someone assist me with find out which driver.find_element_by_*** I can use to find the text in this code (I am looking for all of the search results titles that pop up:

from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium import webdriver

driver = webdriver.Chrome(executable_path=
                          r'/home/littlejiver/Downloads/chromedriver_linux64/chromedriver')
driver.get("https://bestbuy.ca/")

wait = WebDriverWait(driver, 10)
wait.until(ec.element_to_be_clickable((By.XPATH,
                                       '//*[@id="root"]/div/div[4]/header/div/div/div[2]/div/div/div[2]/div/div/form/di'
                                       + 'v/input'))).send_keys("RTX 3060 TI")
wait.until(ec.element_to_be_clickable((By.XPATH,
                                       '//*[@id="root"]/div/div[4]/header/div/div/div[2]/div/div/div[2]/div/div[2]/div/'
                                       + 'ul/li[2]/a'))).click()

# the magic would happen here
results = driver.find_elements_by_class_name('div.a')

for x in results:
    print(x)

and also for bonus points if you know of some guide that may be useful in figuring these sort of question out

Thank you!

littlejiver

question from:https://stackoverflow.com/questions/65889596/text-in-search-results-with-selenium-and-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...