From a868d82bd5e1702c3d81d2d8b7c0e83b8bc1684d Mon Sep 17 00:00:00 2001 From: swpa Date: Thu, 28 May 2026 11:56:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201.=E6=B8=85=E9=99=A4=20ANSI=20=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E7=A2=BC=E3=80=82=202.=E6=B8=85=E9=99=A4=E6=AE=98?= =?UTF-8?q?=E7=95=99=E7=9A=84=20--More--=20=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmts_scraper.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmts_scraper.py b/cmts_scraper.py index f753da5..ab444b3 100644 --- a/cmts_scraper.py +++ b/cmts_scraper.py @@ -372,6 +372,11 @@ async def fetch_raw_config(host: str, username: str, password: str, config_type: await process.stdin.drain() # 簡單清理頭尾的雜訊 (例如指令本身的 echo) + # 1. 清除 ANSI 控制碼 (如顏色、游標移動) 與退格鍵 \x08 + cleaned_output = re.sub(r'\x1b\[[0-9;]*[a-zA-Z]|\x08', '', raw_output) + # 2. 清除殘留的 --More-- 文字 + cleaned_output = re.sub(r'--More--', '', cleaned_output) + lines = raw_output.splitlines() clean_lines = [line for line in lines if not line.startswith(cmd) and not line.startswith("admin@")] return "\n".join(clean_lines).strip()