Using html2text with html utf8



我对html2text 有问题

input = "<h1 itemprop="name">B&#242; 33 M&#243;n</h1>"

我使用

from stripogram import html2text
print html2text(input)
print html2text(input.decode('utf8'))

我的结果

B 33 Mn

结果我需要

Bò 33 món

我该怎么做?

html2text(input)的结果是Unicode。要用print打印它,您需要将它转换为UTF-8:,使其恢复到每个字符8位

from stripogram import html2text
print html2text(input).encode('utf-8')

将打印

# Bò 33 Món

最新更新