Here is an exemple of element from a website I am trying to scrape. None of them have ids or names, they just have long garbage name like in the exemple bellow.
<h1 class="product-name__item product-name__item--name" title="BOEUF HACHE MAIGRE 1 LB">BOEUF HACHE MAIGRE 1 LB</h1>
I tried two things and got 2 different errors.
First attempt :
I tried finding it by class name. This result in a timeout exception.
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, "product-name__item product-name__item--name"))
)
print(element.text)
finally:
driver.quit()
Second attempt:
I tried finding it by css selector because I thought there were a problem with the class name containing a blank space.This resulted in the following error: TypeError: 'str' object is not callable
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located(By.CSS_SELECTOR("[class='product-name__item product-name__item--name']"))
)
print(element.text)
finally:
driver.quit()
Would you have a solution? Thank you and have a nice day!