Python で実体参照のデコード。アポストロフィーの場合…
はまったorz
アポストロフィーの文字実体参照(')は XHTML1.0 からだとか…
>>> import htmlentitydefs >>> htmlentitydefs.name2codepoint['apos'] Traceback (most recent call last): ... KeyError: 'apos'
とりあえず
これでいいのかな
>>> from xml.sax.saxutils import unescape >>> unescape('' " & < >') '' " & < >' >>> unescape('' " & < >', {''': '\'', '"': '"'}) '\' " & < >'