| 
					
				 | 
			
			
				@@ -78,6 +78,21 @@ def remove_prefix_from_url(url): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return url 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def standardize_year_month(filename): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    从文件名中提取年份和月份,并返回标准格式 "YYYY年MM月"。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    :param filename: 文件名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    :return: 标准化的 "YYYY年MM月" 字符串,或 None 如果未找到匹配项 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    # 正则匹配类似 "2025年4月" 的格式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    match = re.search(r'(\d{4})年(\d{1,2})月', filename) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if match: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        year = match.group(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        month = match.group(2)  # 补零 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return f"{year}年{month}月" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def find_target_links(driver, year_month): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     """在当前页面找到符合 TARGET_TITLES 的文件并触发下载""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     # 等待页面加载完成 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -97,7 +112,11 @@ def find_target_links(driver, year_month): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if file_name.startswith('2022'): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 return 'stop' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if not file_name.startswith(year_month): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            standardized = standardize_year_month(file_name) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if standardized is None: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.info(f"非 {year_month} 文件: {file_name}, continue") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                continue 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if standardized != year_month: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 log.info(f"非 {year_month} 文件: {file_name}, stop") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 return 'stop' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if '进口商品' in file_name or '出口商品' in file_name or '分国家' in file_name or '分国别' in file_name or '地市' in file_name: 
			 |