我实际上正在尝试使用curl 检索网页的标题。 我正在使用这个代码:
curl "%URLLink%" --insecure -L > "%HTMLFile%"
但是我得到了一些未格式化的字符,它向我显示了类似这样的内容
<title> La guerre de l'info : Israël / Hamas en replay - Complément d'enquête </title>
而不是
<title> La guerre de l'info : Israël / Hamas en replay - Complément d'enquête </title>
我希望有一种简单的方法可以通过像这样的简单行代码来理解这一点
curl "%URLLink%" --insecure -L | python -m json.tool > "%JSONFile%"
我用它来美化 JSON 中的一些文本。
使用 html.unescape():
import html
print(html.unescape('£682m'))