Bottom Page

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()?
buran wrote Mar-22-2020, 08:26 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.

Please, post the entire traceback that you get. We need to see the whole thing. Do not just give us the last line.
Take a time to read What to include in a post
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Web Scraping Error : Not getting expected result adminravi 4 269 Oct-08-2019, 09:53 AM
Last Post: snippsat
  Scraping data saving to DB error with Cursor cubangt 3 462 May-20-2019, 08:30 PM
Last Post: Yoriz
  Python Scraping Error ZenWoR 1 586 Sep-15-2018, 08:23 PM
Last Post: snippsat
  Error while scraping item price from online store mgtheboss 2 1,663 Jan-12-2018, 06:42 PM
Last Post: snippsat
  Error while scraping links with beautiful soup mgtheboss 4 3,647 Dec-22-2017, 12:41 PM
Last Post: mgtheboss

Forum Jump:


Users browsing this thread: 1 Guest(s)