Sometimes, we want to fix ‘ResultSet’ object has no attribute ‘find_all’ with Python Beautiful Soup.
In this article, we’ll look at how to fix ‘ResultSet’ object has no attribute ‘find_all’ with Python Beautiful Soup.
How to fix ‘ResultSet’ object has no attribute ‘find_all’ with Python Beautiful Soup?
To fix ‘ResultSet’ object has no attribute ‘find_all’ with Python Beautiful Soup, we call find_all
on objects returned in the list returned by find_all
.
For instance, we write
import requests
from bs4 import BeautifulSoup
url = 'http://foo.com'
r = requests.get(url)
soup = BeautifulSoup(r.text)
table = soup.find_all(class_='dataframe')
l = len(table[0].find_all('tr'))
to call soup.find_all
to find all items with class dataframe
.
Then we get the first element from the table
list and call find_all
on that to find tr elements.
Conclusuon
To fix ‘ResultSet’ object has no attribute ‘find_all’ with Python Beautiful Soup, we call find_all
on objects returned in the list returned by find_all
.