mardi 2 novembre 2021

How can i extract data-component attribute using python web scraping

i am trying to scrape data from this url="https://ift.tt/3CFasEm". i am trying to get the title of the item but unfornately whatever i do i cant seem to extrat it properly using python beatifulsoup.

product_name=soup.find_all('div',class_='css-j7qwjs').text

but im getting error like this.

AttributeError Traceback (most recent call last) C:\Users\HPPC~1\AppData\Local\Temp/ipykernel_98396/1955605631.py in ----> 1 product_name=soup.find_all('div',class_='css-j7qwjs').text

~\AppData\Roaming\Python\Python310\site-packages\bs4\element.py in getattr(self, key) 2251 def getattr(self, key): 2252 """Raise a helpful exception to explain a common code fix.""" -> 2253 raise AttributeError( 2254 "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 2255 )

AttributeError: ResultSet object has no attribute 'text'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?

can anyone tell me how can i scrape it properly?




Aucun commentaire:

Enregistrer un commentaire