Reputation: 21
I'm writing a web scraper script
picture = soup.find("div", {"id" : "thumbs-top"})
for link in picture.findAll("img"):
counter += 1
This counter turns out to be 327 which is clearly not true. I was scraping this imgur gallery : http://imgur.com/a/akHsJ?gallery
Upvotes: 2
Views: 2202
Reputation: 13458
I am getting 575.
>>> import requests
>>> from bs4 import BeautifulSoup
>>> r = requests.get('http://imgur.com/a/akHsJ?gallery')
>>> soup = BeautifulSoup(r.text)
>>> picture = soup.find("div", {"id" : "thumbs-top"})
>>> links = picture.findAll("img")
>>> len(links)
575
Edit: In the comments we determined that the problem is fixed by trying a different html parser with BeautifulSoup. See this question for more info.
>>> soup = BeautifulSoup(r.text, 'html.parser')
Upvotes: 2