Reputation: 11
from bs4 import BeautifulSoup
import requests
html_text = requests.get('https://www.uplannerperu.com/shop/').text
#print(html_text)
soup = BeautifulSoup(html_text, 'lxml')
archive = soup.find('div', class_ = 'archive-products')
#print(archive)
ulproducts = archive.find_all('ul')
#print(ulproducts)
productname = ulproducts.find()
print(productname)```
This is my print for error code, and somewhere between the begining of the list and the start of the <li class> is something I don't know that is cracking up.
AttributeError Traceback (most recent call last) in 9 ulproducts = archive.find_all('ul') 10 #print(ulproducts) ---> 11 productname = ulproducts.find('a', href_ = 'https://www.uplannerperu.com/product/botanical-nights-2022/' class="ansi-yellow-intense-fg ansi-bold">) 12 print(productname)
~\anaconda3\lib\site-packages\bs4\element.py in getattr(self, key) 2171 def getattr(self, key): 2172 """Raise a helpful exception to explain a common code fix.""" -> 2173 raise AttributeError( 2174 "ResultSet object has no attribute '%s'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?" % key 2175 )
AttributeError: ResultSet object has no attribute 'find'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?```
I'm trying to scrape all of the products at once, but i Had this parse problem with the HTML Code.
Upvotes: 0
Views: 555
Reputation: 124
In the penultimate line you are not passing anything to the find() method, and by using ulproducts = archive.find_all('ul')
, you are getting an array
productname = ulproducts.find()
Upvotes: 1