このページはUTF-8でエンコードされていますが、PythonのHTMLParserではうまく動作しますが、UnicodeDecodeError
はありませんが、BeautifulSoupで解析しようとするとエラーが発生します。 私は_*_
コーディングしようとしました:どこでもutf-8 _*_
、.encode('utf-8')
をしてもエラーには、PythonのBeautifulSoupでエンコードされています
import urllib
from BeautifulSoup import BeautifulSoup
args=urllib.urlencode({'keywords':'magic'})
doc=urllib.urlopen('http://www.example.com/submit', args)
soup=BeautifulSoup(doc)
stuff = soup.findAll('section',id='banner')
print stuff
Traceback (most recent call last):
File "test.py", line 7, in <module>
print stuff
UnicodeEncodeError: 'ascii' codec can't encode character u'\xed' in position 112: ordinal not in range(128)