urllib.unquoteで出来るよって?違うそれは「URLエンコード」別件です。紛らわしいよHTML業界。
- HTMLエスケープは、特殊文字とHTMLタグを避けるための小細工
- URLエンコードは、特殊文字を、HTTP GETクエリストリングを避けるための小細工
結論から言うと、次のうち幾つか。らしい。
- BeautifulSoup.BeautifulSoup.soup.find(str).string / html.fromstring(text).text http://stackoverflow.com/questions/2087370/decode-html-entities-in-python-string
- BeautifulSoup.BeautifulSoup(str, convertEntities=BeautySoup.HTML_ENTITIES )
- HTMLParser.HTMLParser().unescape http://docs.python.org/library/htmlparser.html
- xml.sax.saxutils.escape / xml.sax.saxutils.unescape
- htmlentitydef を使って地道に変換 http://www.opensource.apple.com/source/python/python-3/python/Lib/htmlentitydefs.py
別パッケージを入れなきゃならんのは色々アレなので、
- from xml.sax.saxutils import escape,unescape
辺りで行ってみようかと