Why does this not work, when there is <br>
in the text? I get an empty text.
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
address = 'http://www.bbc.com'
response = opener.open(address)
html = response.read()
soup = BeautifulSoup(html)
snaptext = soup.find('p', attrs={'class': 'displaytext'})
print snaptext.string
An example, would be:
< p > blahblahblah< br/ >blah2blah2blah2< br/ >< p >
If there's a < br >
in the text, the result is None