-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
Hi guys. I'm trying using NODRIVER to extract attributes from tags and text. But there's an error.
Error data extract: 'coroutine' object has no attribute 'attributes'
Error data extract: 'coroutine' object has no attribute 'attributes'
Error data extract: 'coroutine' object has no attribute 'attributes'
Error data extract: 'coroutine' object has no attribute 'attributes'
Error data extract: 'coroutine' object has no attribute 'attributes'
The documentation mentions Element.attributes. but...
maybe I need to rewrite the code differently?!!
I'd be grateful for any hint!!!
products = await page.query_selector_all('.lu-grid__item')
product_list = []
for product in products[:5]:
try:
title_element = product.query_selector('a .lu-product-card-name')
attributes = title_element.attributes
title = attributes.get('title')
print(title)
price_element = product.query_selector('.product-card-main-content .price-and-buttons .main-price')
price = price_element.text
print(price)
url_element = product.query_selector('a')
attributes = url_element.attributes
url = attributes.get('href')
print(url)
product_list.append({
"title": title,
"price": price,
"url": url
})
except Exception as e:
print(f"Error data extract: {e}")
Metadata
Metadata
Assignees
Labels
No labels