Posts Tagged ‘_detectEncoding’
September 30, 2012 Leave a comment
While parsing an HTML page with BeautifulSoup, I got a similar error message:
File ".../BeautifulSoup.py", line 1915, in _detectEncoding '^<\?.*encoding=[\'"](.*?)[\'"].*\?>').match(xml_data) TypeError: expected string or buffer
In the code I had this:
text = get_page(url) soup = BeautifulSoup(text)
text = get_page(url) text = str(text) # here is the trick soup = BeautifulSoup(text)
Tip from here.