Im trying to webscrape all snapple facts on https://www.snapple.com/real-facts right now, and since I didnt find anything useful online, I decided to write my own script
from bs4 import BeautifulSoup as soup
import requests
data = requests.get('https://www.snapple.com/real-facts')
result_list = []
soup = soup(data.text, 'html.parser')
divs = soup.find("div", {'id':'facts'})
for div in divs:
fact_li = div.find('li')
for fact in fact_li:
spans = fact.find('span', {'class':'description'})
for span in spans:
a = fact.find('a')
result_list.append(a)
print(result_list)
when I run this it returns:
Traceback (most recent call last):
File "snapplefactscrape.py", line 11, in <module>
for fact in fact_li:
TypeError: 'int' object is not iterable
I get what that means, but I dont understand why the fact_li is an int, and how I can prevent it from being one.
Help would be appreciated :)