When I print the title I'm getting this error
selenium.common.exceptions.InvalidArgumentException: Message: unknown variant //h4[@class='css-2fgx4k'], expected one of css selector, link text, partial link Текст , имя тега , xpath в строке 1 столбец 37
Код: Выделить всё
from RPA.Browser.Selenium import Selenium
# Search term
search_term = "climate change"
# Open the NY Times search page and search for the term
browser = Selenium()
browser.open_available_browser("https://www.nytimes.com/search?query=" + search_term)
# Find all the search result articles
articles = browser.find_elements("//ol[@data-testid='search-results']/li")
# Extract title, date, and description for each article and add to the list
for article in articles:
# Extract the title
title = article.find_element("//h4[@class='css-2fgx4k']")
print(title)
# Close the browser window
browser.close_all_browsers()
Подробнее здесь: https://stackoverflow.com/questions/762 ... aframework