From 4e0ec678dfdfb9f0abf5bc53000175e562eb4f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B8=A2=E4=BD=8E=E5=90=B8?= Date: Sat, 29 Jul 2023 19:48:19 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20=E7=A7=BB=E9=99=A4=20tw165=20?= =?UTF-8?q?=E7=B4=94=20ip=20=E7=9A=84=E7=B4=80=E9=8C=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AutoBuild/tw_165.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/AutoBuild/tw_165.py b/AutoBuild/tw_165.py index c1b5a31..259dfe1 100644 --- a/AutoBuild/tw_165.py +++ b/AutoBuild/tw_165.py @@ -3,13 +3,18 @@ from requests.auth import HTTPBasicAuth from json.decoder import JSONDecodeError import logging import os -from typing import List +import re from urllib.parse import urlparse logger = logging.getLogger(__name__) +def is_pure_ip(domain: str) -> bool: + pattern = r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$' + return True if re.match(pattern, domain) else False + + def main(): auth = os.getenv('auth', None) jsonurl = os.getenv('tw165json', None) @@ -51,6 +56,8 @@ def main(): ] )) + # 移除純 IP + domains = {k: v for k, v in domains.items() if not is_pure_ip(k)} filename = 'TW165.txt' with open(filename, 'w') as f: f.write('^\n'.join('||' + e for e in domains.keys()))