from tools import * from Utils.Config import * from Utils.Lib import * from AppBridge import * # pip install beautifulsoup4 jsbeautifier cssbeautifier from bs4 import BeautifulSoup import jsbeautifier import cssbeautifier CUSTOM_MIME_MAP = { "application/json": ".json", "text/html": ".html", "text/css": ".css", "text/javascript": ".js", "text/plain": ".txt", } # ------------------- HTML 压缩 ------------------- def CompressHtml(html_str: str) -> str: """ 压缩 HTML 字符串(移除多余空白、注释,保留核心结构) :param html_str: 原始 HTML 字符串 :return: 压缩后的 HTML 字符串 """ # 解析 HTML soup = BeautifulSoup(html_str, "html.parser") # 移除所有注释节点 for comment in soup.find_all(string=lambda text: isinstance(text, str) and text.strip().startswith('