I want to scrape a page from a website that includes the following HTML:
<div class="section"><div ng-bind="1" class="item even">First item</div><div ng-bind="2" class="item odd">Second item</div><div ng-bind="3" class="item-alt even">Third item</div></div>
Here is my code:
from bs4 import BeautifulSoupfrom urllib import requestmy_url = 'https://some.site/some/file.html?param=value'with request.urlopen(my_url) as r: soup = BeautifulSoup(r.read(), "html.parser")result = soup.findAll('item')print(result)
But I get an empty list as a result ([]
). I also tried:
result = soup.find('item')print(result)
But that prints None
.
Why doesn't my code find the items? I can see the items on the page, so I know they are there?