From dfc557b2df8b48b276f10d36ee669dfe44053cbd Mon Sep 17 00:00:00 2001 From: g1879 Date: Mon, 4 Jan 2021 17:19:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84format=5Fhtml()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/common.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/DrissionPage/common.py b/DrissionPage/common.py index d4a7044..b70b8e2 100644 --- a/DrissionPage/common.py +++ b/DrissionPage/common.py @@ -5,7 +5,7 @@ @File : common.py """ from abc import abstractmethod -# from html import unescape +from html import unescape from pathlib import Path from re import split as re_SPLIT from shutil import rmtree @@ -217,20 +217,15 @@ def _make_search_str(search_str: str) -> str: return search_str -def format_html(text: str, replace_space: bool = True) -> str: +def format_html(text: str, trans: bool = True) -> str: """处理html编码字符""" if not text: return text - # text = unescape(text) + if trans: + text = unescape(text) - # if '&' in text: - # html = unescape(text) - - if replace_space: - text = text.replace('\xa0', ' ') - - return text + return text.replace('\xa0', ' ') def translate_loc(loc: tuple) -> tuple: