問題:
I'm parsing some HTML with Beautiful Soup 3, but it contains HTML entities which Beautiful Soup 3 doesn't automatically decode for me:我正在使用 Beautiful Soup 3 解析一些 HTML,但它包含 Beautiful Soup 3 不會自動爲我解碼的 HTML 實體:
>>> from BeautifulSoup import BeautifulSoup
>>> soup = BeautifulSoup("<p>£682m</p>")
>>> text = soup.find("p").string
>>> print text
£682m
How can I decode the HTML entities in text
to get "£682m"
instead of "£682m"
.如何解碼text
的 HTML 實體以獲得"£682m"
而不是"£682m"
。
解決方案:
參考一: https://en.stackoom.com/question/8l1G參考二: https://stackoom.com/question/8l1G