From 39a307c4073d968345da43fba681f04a1eed3d00 Mon Sep 17 00:00:00 2001 From: frxz751113 <156018267+frxz751113@users.noreply.github.com> Date: Tue, 27 Aug 2024 22:39:42 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E7=BD=91=E7=BB=9C=E6=94=B6=E9=9B=86.p?= =?UTF-8?q?y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py/网络收集.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/py/网络收集.py b/py/网络收集.py index 2159634..a93bb17 100644 --- a/py/网络收集.py +++ b/py/网络收集.py @@ -367,7 +367,6 @@ parse_file('2.txt', '2.txt') -############################################################################检测同IP第一个链接,缩小验源数量 import cv2 import time from tqdm import tqdm @@ -403,6 +402,7 @@ with open(output_file_path, 'w', encoding='utf-8') as output_file: url = url.strip() # 构造IP键 ip_key = get_ip_key(url) + # 检查IP键是否存在 if ip_key and ip_key in detected_ips: # 如果IP键已存在,根据之前的结果决定是否写入新文件 if detected_ips[ip_key]['status'] == 'ok': @@ -412,21 +412,22 @@ with open(output_file_path, 'w', encoding='utf-8') as output_file: cap = cv2.VideoCapture(url) start_time = time.time() frame_count = 0 - # 尝试捕获10秒内的帧 - while frame_count < 10 and (time.time() - start_time) < 3: + # 尝试捕获4秒内的帧 + while frame_count < 7 and (time.time() - start_time) < 4: ret, frame = cap.read() if not ret: break frame_count += 1 # 释放资源 cap.release() + # 根据捕获的帧数判断状态并记录结果 - if frame_count >= 10: #10秒内超过230帧则写入 + if frame_count >= 7: # 10秒内超过10帧则写入 detected_ips[ip_key] = {'status': 'ok'} output_file.write(line) # 写入检测通过的行 else: detected_ips[ip_key] = {'status': 'fail'} -# 打印2 +# 打印结果 for ip_key, result in detected_ips.items(): print(f"IP Key: {ip_key}, Status: {result['status']}")