From 5ceb7b9c1a9466b3a677b90a2a1a5cac69987d01 Mon Sep 17 00:00:00 2001 From: frxz751113 <156018267+frxz751113@users.noreply.github.com> Date: Mon, 26 Aug 2024 21:58:25 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E6=94=B6=E9=9B=86.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py/收集.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/py/收集.py b/py/收集.py index 9ed0f1a..e3e9c86 100644 --- a/py/收集.py +++ b/py/收集.py @@ -298,11 +298,12 @@ file_path = "网络收集.txt" output_file_path = "网络收集.txt" def get_ip_key(url): - """从URL中提取IP地址,并构造一个唯一的键""" - # 找到'//'到第一个'/'之间的字符串 + """从URL中提取后面的16个字符作为IP地址键""" + # 找到'://'之后的位置 start = url.find('://') + 3 # '://'.length 是 3 - end = url.find('/', start) # 找到第一个'/'的位置 - return url[start:end] if end != -1 else None + # 截取start位置后面16个字符 + ip_key = url[start:start + 10] + return ip_key # 打开输入文件和输出文件 with open(file_path, 'r', encoding='utf-8') as file: