This commit is contained in:
BF
2026-05-06 16:30:59 +08:00
parent 83ab7a79e8
commit c2276f17f4
36 changed files with 432386 additions and 543 deletions

View File

@@ -1196,15 +1196,21 @@ class DetectWorker:
success, message, seo_data = chinaz.check_title(domain_name, sensitive_words, proxy)
if not success:
logger.warning(f"站长之家检测未通过: {domain_name}, 原因: {message}")
# 如果是 'failure' 则不拉黑,继续执行下一个检测
if message != 'failure':
# 如果是 'failure' 或网络连接错误,则不拉黑,继续执行下一个检测
error_keywords = ['failure', 'timeout', 'timed out', 'max retries exceeded', 'too many open files', 'connection aborted', 'connectionabortederror']
should_blacklist = True
for keyword in error_keywords:
if keyword in message.lower():
should_blacklist = False
break
if should_blacklist:
# 将域名加入黑名单
self.db.update_domain_detect_status(domain_id, 4) # 4 表示黑名单
self.db.add_to_blacklist(domain_name, message)
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
else:
logger.info(f"站长之家检测返回 failure,不拉黑域名: {domain_name}")
logger.info(f"站长之家检测返回 {message},不拉黑域名: {domain_name}")
logger.info(f"站长之家检测完成: {domain_name}")
except Exception as e:
logger.error(f"站长之家检测失败: {domain_name}, 错误: {e}")
@@ -1221,15 +1227,21 @@ class DetectWorker:
success, message = aizhan.check_aizhan(domain_name, sensitive_words, proxy)
if not success:
logger.warning(f"爱站网检测未通过: {domain_name}, 原因: {message}")
# 如果是 'failure' 则不拉黑,继续执行下一个检测
if message != 'failure':
# 如果是 'failure' 或网络连接错误,则不拉黑,继续执行下一个检测
error_keywords = ['failure', 'timeout', 'timed out', 'max retries exceeded', 'too many open files', 'connection aborted', 'connectionabortederror']
should_blacklist = True
for keyword in error_keywords:
if keyword in message.lower():
should_blacklist = False
break
if should_blacklist:
# 将域名加入黑名单
self.db.update_domain_detect_status(domain_id, 4) # 4 表示黑名单
self.db.add_to_blacklist(domain_name, message)
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
else:
logger.info(f"爱站网检测返回 failure,不拉黑域名: {domain_name}")
logger.info(f"爱站网检测返回 {message},不拉黑域名: {domain_name}")
logger.info(f"爱站网检测完成: {domain_name}")
except Exception as e:
logger.error(f"爱站网检测失败: {domain_name}, 错误: {e}")
@@ -1246,26 +1258,47 @@ class DetectWorker:
success, message = baidu.check_site(domain_name, sensitive_words, proxy)
if not success:
logger.warning(f"百度site检测未通过: {domain_name}, 原因: {message}")
# 如果是代理导致的失败,尝试不使用代理重新检测
if 'proxy' in locals() and locals()['proxy'] and ('timeout' in message.lower() or 'connection' in message.lower()):
logger.info(f"代理检测失败,尝试不使用代理重新检测: {domain_name}")
success, message = baidu.check_site(domain_name, sensitive_words, None)
if success:
logger.info(f"不使用代理检测百度成功: {domain_name}")
# 检查是否是网络连接错误
error_keywords = ['timeout', 'timed out', 'max retries exceeded', 'too many open files', 'connection aborted', 'connectionabortederror']
is_network_error = False
for keyword in error_keywords:
if keyword in message.lower():
is_network_error = True
break
if is_network_error:
# 如果是网络连接错误,不拉黑,继续执行下一个检测
logger.info(f"百度site检测返回网络错误 {message},不拉黑域名: {domain_name}")
else:
# 如果是代理导致的失败,尝试不使用代理重新检测
if 'proxy' in locals() and locals()['proxy']:
logger.info(f"代理检测失败,尝试不使用代理重新检测: {domain_name}")
success, message = baidu.check_site(domain_name, sensitive_words, None)
if success:
logger.info(f"不使用代理检测百度成功: {domain_name}")
else:
# 检查重新检测是否也是网络连接错误
is_retry_network_error = False
for keyword in error_keywords:
if keyword in message.lower():
is_retry_network_error = True
break
if is_retry_network_error:
logger.info(f"不使用代理检测百度返回网络错误 {message},不拉黑域名: {domain_name}")
else:
logger.warning(f"不使用代理检测百度仍未通过: {domain_name}, 原因: {message}")
# 将域名加入黑名单
self.db.update_domain_detect_status(domain_id, 4) # 4 表示黑名单
self.db.add_to_blacklist(domain_name, message)
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
else:
logger.warning(f"不使用代理检测百度仍未通过: {domain_name}, 原因: {message}")
# 其他原因导致的失败,直接加入黑名单
# 将域名加入黑名单
self.db.update_domain_detect_status(domain_id, 4) # 4 表示黑名单
self.db.add_to_blacklist(domain_name, message)
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
else:
# 其他原因导致的失败,直接加入黑名单
# 将域名加入黑名单
self.db.update_domain_detect_status(domain_id, 4) # 4 表示黑名单
self.db.add_to_blacklist(domain_name, message)
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
logger.info(f"百度site检测完成: {domain_name}")
except Exception as e:
logger.error(f"百度site检测失败: {domain_name}, 错误: {e}")
@@ -1276,22 +1309,41 @@ class DetectWorker:
try:
logger.info(f"尝试不使用代理重新检测百度: {domain_name}")
success, message = baidu.check_site(domain_name, sensitive_words, None)
if success:
logger.info(f"不使用代理检测百度成功: {domain_name}")
else:
logger.warning(f"不使用代理检测百度仍未通过: {domain_name}, 原因: {message}")
# 将域名加入黑名单
self.db.update_domain_detect_status(domain_id, 4) # 4 表示黑名单
self.db.add_to_blacklist(domain_name, message)
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
if not success:
# 检查是否是网络连接错误
error_keywords = ['timeout', 'timed out', 'max retries exceeded', 'too many open files', 'connection aborted', 'connectionabortederror']
is_network_error = False
for keyword in error_keywords:
if keyword in message.lower():
is_network_error = True
break
if is_network_error:
logger.info(f"不使用代理检测百度返回网络错误 {message},不拉黑域名: {domain_name}")
else:
logger.warning(f"不使用代理检测百度未通过: {domain_name}, 原因: {message}")
# 将域名加入黑名单
self.db.update_domain_detect_status(domain_id, 4) # 4 表示黑名单
self.db.add_to_blacklist(domain_name, message)
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
logger.info(f"不使用代理检测百度成功: {domain_name}")
except Exception as e2:
logger.error(f"不使用代理检测百度也失败: {domain_name}, 错误: {e2}")
# 将域名加入黑名单
self.db.update_domain_detect_status(domain_id, 4) # 4 表示黑名单
self.db.add_to_blacklist(domain_name, str(e2))
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
# 检查是否是网络连接错误
error_keywords = ['timeout', 'timed out', 'max retries exceeded', 'too many open files', 'connection aborted', 'connectionabortederror']
is_network_error = False
for keyword in error_keywords:
if keyword in str(e2).lower():
is_network_error = True
break
if is_network_error:
logger.info(f"不使用代理检测百度返回网络错误 {str(e2)},不拉黑域名: {domain_name}")
else:
# 将域名加入黑名单
self.db.update_domain_detect_status(domain_id, 4) # 4 表示黑名单
self.db.add_to_blacklist(domain_name, str(e2))
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
# 5. 360的site查询
if self.detect_options.get('detect_360_site', True):
@@ -1300,15 +1352,21 @@ class DetectWorker:
passed, message = c360.check_domain(domain_name, sensitive_words, self.get_proxies())
if not passed:
logger.warning(f"360检测未通过: {domain_name}, 原因: {message}")
# 如果是 'failure' 则不拉黑,继续执行下一个检测
if message != 'failure':
# 如果是 'failure' 或网络连接错误,则不拉黑,继续执行下一个检测
error_keywords = ['failure', 'timeout', 'timed out', 'max retries exceeded', 'too many open files', 'connection aborted', 'connectionabortederror']
should_blacklist = True
for keyword in error_keywords:
if keyword in message.lower():
should_blacklist = False
break
if should_blacklist:
# 将域名加入黑名单
self.db.update_domain_detect_status(domain_id, 4) # 4 表示黑名单
self.db.add_to_blacklist(domain_name, message)
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
else:
logger.info(f"360检测返回 failure,不拉黑域名: {domain_name}")
logger.info(f"360检测返回 {message},不拉黑域名: {domain_name}")
logger.info(f"360检测完成: {domain_name}")
except Exception as e:
logger.error(f"360检测失败: {domain_name}, 错误: {e}")
@@ -1348,6 +1406,8 @@ class DetectWorker:
self.db.add_to_blacklist(domain_name, "域名状态包含clientHold或serverHold")
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
# 更新检测状态为已检测
self.db.update_detection_status(domain_id, 'whois', 1)
logger.info(f"聚查WHOIS检测完成: {domain_name}")
except Exception as e:
logger.error(f"聚查WHOIS检测失败: {domain_name}, 错误: {e}")
@@ -1377,6 +1437,8 @@ class DetectWorker:
pass
# 更新数据库
self.db.update_domain_beian_info(domain_id, company_type, website_url, has_beian_flag, beian_year)
# 更新检测状态为已检测
self.db.update_detection_status(domain_id, 'beian', 1)
logger.info(f"聚查备案检测完成: {domain_name}")
except Exception as e:
logger.error(f"聚查备案检测失败: {domain_name}, 错误: {e}")
@@ -1421,6 +1483,8 @@ class DetectWorker:
self.db.add_to_blacklist(domain_name, reason_str)
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
# 更新检测状态为已检测
self.db.update_detection_status(domain_id, 'intercept', 1)
logger.info(f"聚查拦截检测完成: {domain_name}")
except Exception as e:
logger.error(f"聚查拦截检测失败: {domain_name}, 错误: {e}")
@@ -1433,11 +1497,17 @@ class DetectWorker:
success, message = self.juziseo_instance.check_history(domain_name, sensitive_words)
if not success:
logger.warning(f"桔子历史检测未通过: {domain_name}, 原因: {message}")
# 将域名加入黑名单
self.db.update_domain_detect_status(domain_id, 4) # 4 表示黑名单
self.db.add_to_blacklist(domain_name, message)
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
# 如果是会话超时错误,则不拉黑,继续执行下一个检测
if '会话超时' not in message and '重新登录' not in message:
# 将域名加入黑名单
self.db.update_domain_detect_status(domain_id, 4) # 4 表示黑名单
self.db.add_to_blacklist(domain_name, message)
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
else:
logger.info(f"桔子历史检测返回 {message},不拉黑域名: {domain_name}")
# 更新检测状态为已检测
self.db.update_detection_status(domain_id, 'juziseo_history', 1)
logger.info(f"桔子历史检测完成: {domain_name}")
except Exception as e:
logger.error(f"桔子历史检测失败: {domain_name}, 错误: {e}")
@@ -1450,17 +1520,51 @@ class DetectWorker:
success, message = self.juziseo_instance.check_external_link(domain_name, sensitive_words)
if not success:
logger.warning(f"桔子外链检测未通过: {domain_name}, 原因: {message}")
# 将域名加入黑名单
self.db.update_domain_detect_status(domain_id, 4) # 4 表示黑名单
self.db.add_to_blacklist(domain_name, message)
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
# 如果是会话超时错误,则不拉黑,继续执行下一个检测
if '会话超时' not in message and '重新登录' not in message:
# 将域名加入黑名单
self.db.update_domain_detect_status(domain_id, 4) # 4 表示黑名单
self.db.add_to_blacklist(domain_name, message)
logger.info(f"域名已加入黑名单: {domain_name}")
return # 检测未通过,直接返回
else:
logger.info(f"桔子外链检测返回 {message},不拉黑域名: {domain_name}")
# 更新检测状态为已检测
self.db.update_detection_status(domain_id, 'juziseo_outlink', 1)
logger.info(f"桔子外链检测完成: {domain_name}")
except Exception as e:
logger.error(f"桔子外链检测失败: {domain_name}, 错误: {e}")
# 更新检测状态为已完成
self.db.update_domain_detect_status(domain_id, 1) # 1 表示检测完成
# 检查是否所有检测选项都已完成
all_detected = True
if self.detect_options.get('detect_whois', False):
status = self.db.get_detection_statuses(domain_id)
if status.get('whois_status', 0) != 1:
all_detected = False
if self.detect_options.get('detect_beian', False):
status = self.db.get_detection_statuses(domain_id)
if status.get('beian_status', 0) != 1:
all_detected = False
if self.detect_options.get('detect_intercept', False):
status = self.db.get_detection_statuses(domain_id)
if status.get('intercept_status', 0) != 1:
all_detected = False
if self.detect_options.get('detect_juziseo', False):
status = self.db.get_detection_statuses(domain_id)
if status.get('juziseo_history_status', 0) != 1:
all_detected = False
if self.detect_options.get('detect_juziseo_outlink', False):
status = self.db.get_detection_statuses(domain_id)
if status.get('juziseo_outlink_status', 0) != 1:
all_detected = False
# 只有当所有检测选项都已完成时,才更新检测状态为已完成
if all_detected:
self.db.update_domain_detect_status(domain_id, 1) # 1 表示检测完成
# 更新检测时间
from datetime import datetime
current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
self.db.update_domain_detect_time(domain_id, current_time)
# 检查是否满足特定条件如果满足且expire_date不为空则将其置空
try:
@@ -1554,7 +1658,7 @@ class DetectWorker:
while self.running:
# 获取需要检测的域名
domains = self.db.get_domains_to_detect(limit=batch_size)
domains = self.db.get_domains_to_detect(limit=batch_size, detect_options=self.detect_options)
current_batch_size = len(domains)
logger.info(f"获取到 {current_batch_size} 个需要检测的域名")