So I parsed a html page with .findAll (BeautifulSoup) to variable named result.
If I type result in Python shell then press Enter, I see normal text as expected, but as I wanted to postprocess this result as string object, I noticed that str(result) returns garbage, like this sample:
\xd1\x87\xd0\xb8\xd0\xbb\xd0\xbd\xd0\xb8\xd1\x86\xd0\xb0</a><br />\n<hr />\n</div>
Html page source is utf-8 encoded
How can I handle this?
Code is basically this, in case it matters:
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup(urllib.open(url).read())
result = soup.findAll(something)
Python is 2.7
Python 2.6.7
BeautifulSoup.version 3.2.0
This worked for me:
I’m pretty sure a
resultis aBeautifulSoup.ResultSetobject, which seems to be an extension of the standard python list