Kaynağa Gözat

Fix 修复部分附件丢失的问题

yue 3 hafta önce
ebeveyn
işleme
be783420d9

+ 10 - 2
SourceCode/TenderCrawler/app/adapters/ccgp_data_collection_adapter.py

@@ -208,12 +208,14 @@ class CcgpDataCollectionAdapter(IDataCollectionAdapter):
             By.XPATH, "//td[@class='bid_attachtab_content']/a"
         )
         attach_2_els = self.driver.find_elements(By.XPATH, "//a[@ignore='1']")
-
         # 合并两个列表
         all_attachments = attach_els + attach_2_els
+        utils.get_logger().debug(
+            f"附件检索数量: {len(attach_els)}/{len(attach_2_els)}/{len(all_attachments)}"
+        )
         attach_urls = []
         if len(all_attachments) > 0:
-            for attach_el in attach_els:
+            for attach_el in all_attachments:
                 attach_url = attach_el.get_attribute("href")
                 if attach_url not in attach_urls:
                     attach_urls.append(attach_url)
@@ -233,9 +235,15 @@ class CcgpDataCollectionAdapter(IDataCollectionAdapter):
                         f"文件名 {file_name} 不包含扩展名,跳过下载。"
                     )
                     continue
+                utils.get_logger().debug(
+                    f"开始下载附件: {file_name} 链接: {attach_url}"
+                )
                 path = utils.download_remote_file(attach_url, file_name)
                 if path:
+                    utils.get_logger().debug(f"下载附件路径: {path}")
                     paths.append(path)
+                else:
+                    utils.get_logger().warning(f"下载附件失败: {file_name}")
         attach_str = ",".join(paths)
         if attach_str:
             utils.get_logger().info(f"附件下载完成: {attach_str}")