Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Web scraping error
#1
AttributeError: ResultSet object has no attribute 'find'. You're probably treating a list of items like a single item. Did you call find_all() when you meant to call find()?

what is this error?

My code given below

while True:
    response= requests.get(url)
    response    
    data=response.text
    soup= BeautifulSoup(data,'html.parser') 
    apis=soup.find_all('tr',{"class":"odd views-row-first"})

    for api in apis:
        name= apis.find('td',{"class":"views-field views-field-pw-version-title"}).text
        des=apis.find('td',{'class':'views-field views-field-search-api-excerpt views-field-field-api-description hidden-xs visible-md visible-sm col-md-8'}).text
        category=apis.find('td',{'class':'views-field views-field-field-article-primary-category'}).text
        link= apis.find('a',{'class':'views-field views-field-pw-version-title'}).get('href')
        
        print('Name:',name,'\nDescription:', des ,'\ncategory', category ,'\nLink', link)
    url_tag=soup.find('a',{'title':'Go to next page'})
    if url_tag.get('href'):
        url= url_tag.get('href')
        print(url)
    else:
        break

AttributeError Traceback (most recent call last)
<ipython-input-26-1d8b226e6115> in <module>
7
8 for api in apis:
----> 9 name= apis.find('td',{"class":"views-field views-field-pw-version-title"}).text
10 des=apis.find('td',{'class':'views-field views-field-search-api-excerpt views-field-field-api-description hidden-xs visible-md visible-sm col-md-8'}).text
11 category=apis.find('td',{'class':'views-field views-field-field-article-primary-category'}).text

~\Anaconda3\lib\site-packages\bs4\element.py in __getattr__(self, key)
1576 def __getattr__(self, key):
1577 raise AttributeError(
-> 1578 "ResultSet object has no attribute '%s'. You're probably treating a list of items like a single item. Did you call find_all() when you meant to call find()?" % key
1579 )

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  I am scraping a web page but got an Error Sarmad54 3 1,452 Mar-02-2023, 08:20 PM
Last Post: Sarmad54
  error in code web scraping alexisbrunaux 5 3,797 Aug-19-2020, 02:31 AM
Last Post: alexisbrunaux
  error zomato scraping data syxzetenz 3 3,360 Jun-23-2020, 08:53 PM
Last Post: Gribouillis
  Web Scraping Error : Not getting expected result adminravi 4 2,386 Oct-08-2019, 09:53 AM
Last Post: snippsat
  Scraping data saving to DB error with Cursor cubangt 3 2,778 May-20-2019, 08:30 PM
Last Post: Yoriz
  Python Scraping Error ZenWoR 1 2,238 Sep-15-2018, 08:23 PM
Last Post: snippsat
  Error while scraping item price from online store mgtheboss 2 5,228 Jan-12-2018, 06:42 PM
Last Post: snippsat
  Error while scraping links with beautiful soup mgtheboss 4 8,358 Dec-22-2017, 12:41 PM
Last Post: mgtheboss

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020