Reputation:
MyAlphaSoup = BeautifulSoup(website_to_crawl.text, 'html.parser')
MyAlphaSoup.prettify()
MyAlphaAlphaSoup = MyAlphaSoup.find_all("div", {"class": "lister-item featurefilm"})
MyAlphaAlphaSoup.prettify()
I am getting an error at the 4th line
raise AttributeError( AttributeError: ResultSet object has no attribute 'prettify'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?
Isn't soup.find_all merely reducing the soup to a smaller subset? so the type isn't changing?
Upvotes: 1
Views: 463
Reputation: 840
That's because the function find_all returns a list. So, you should be able to do that if you specify the element of the list or loop through them:
my_alpha_soup = BeautifulSoup(website_to_crawl.text, 'html.parser')
my_alpha_soup.prettify()
list_of_elements = my_alpha_soup.find_all("div", {"class": "lister-item featurefilm"})
for element in list_of_elements:
print(element.prettify())
Also, is a convention to only use initial capital letters for classes.
Upvotes: 2