From 5887b836986972d262b8472d6392374a103a8b7e Mon Sep 17 00:00:00 2001 From: Bairly <2652270566@qq.com> Date: Tue, 1 Apr 2025 19:56:57 +0800 Subject: [PATCH] fix:covers_analyser --- .idea/.name | 1 + .idea/misc.xml | 2 +- .idea/statistics_model2025.iml | 2 +- covers_analyser.py | 16 +++++++++++++--- 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 .idea/.name diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..6727a46 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +covers_analyser.py \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 98a0d17..72cda9f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/.idea/statistics_model2025.iml b/.idea/statistics_model2025.iml index cd2e5af..07abf20 100644 --- a/.idea/statistics_model2025.iml +++ b/.idea/statistics_model2025.iml @@ -2,7 +2,7 @@ - + diff --git a/covers_analyser.py b/covers_analyser.py index f50bed9..231f6df 100644 --- a/covers_analyser.py +++ b/covers_analyser.py @@ -122,10 +122,20 @@ def process_url(url): # 批量处理 def batch_process(urls, workers=4): + # 创建包含所有URL的初始结果列表 + results = [{'url': url, 'success': False} for url in urls] + with Pool(workers) as pool: - results = [res for res in tqdm(pool.imap(process_url, urls), - total=len(urls), - desc="处理进度") if res is not None] + processed = list(tqdm(pool.imap(process_url, urls), + total=len(urls), + desc="处理进度")) + + # 按原始顺序更新成功处理的结果 + for i, res in enumerate(processed): + if res is not None: + results[i] = res + results[i]['success'] = True + return pd.DataFrame(results)