# -*- coding: UTF-8 -*- ''' @Project :domainScanDemo @File :juziseo_detector.py @IDE :PyCharm @Author :梦伴 @Date :2026/4/9 0:03 @explain : 桔子SEO检测器 ''' import requests from curl_cffi import requests as curl_requests import re from app.detectors.base import BaseDetector class JuziseoDetector(BaseDetector): """ 桔子SEO检测器 """ def __init__(self): """ 初始化桔子SEO检测器 """ super().__init__() self.url = 'https://seo.juziseo.com' self.history_url = 'https://seo.juziseo.com/history/{domain}' self.backlink_url = 'https://seo.juziseo.com/backlink/{domain}' def check_domain(self, domain): """ 检测域名 :param domain: 域名 :return: dict - 检测结果 """ try: # 检查历史信息 history_result = self.check_history(domain) # 检查外链 backlink_result = self.check_backlink(domain) return { 'history': history_result, 'backlink': backlink_result } except Exception as e: return self._handle_exception(e, domain) def check_history(self, domain): """ 检查历史信息 :param domain: 域名 :return: dict - 检测结果 """ try: # 构建查询URL query_url = self.history_url.format(domain=domain) headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36' } # 使用curl_cffi模拟浏览器 response = curl_requests.get(query_url, headers=headers, impersonate='chrome', timeout=10) if response.status_code == 200: content = response.text # 提取历史信息 history_info = self._extract_history_info(content) # 检查是否包含敏感词 has_sensitive = self._check_sensitive(history_info) # 检查是否有百度历史收录 has_baidu_history = '百度历史收录' in content # 检查是否有子域名 has_subdomains = '子域名' in content # 检查是否为简体中文 is_simplified = self._check_simplified(content) return { 'has_sensitive': has_sensitive, 'has_baidu_history': has_baidu_history, 'has_subdomains': has_subdomains, 'is_simplified': is_simplified } else: self._log_warning(f"桔子SEO历史查询失败: {response.status_code}") return {'has_sensitive': False, 'has_baidu_history': False, 'has_subdomains': False, 'is_simplified': True} except Exception as e: self._handle_exception(e, domain) return {'has_sensitive': False, 'has_baidu_history': False, 'has_subdomains': False, 'is_simplified': True} def check_backlink(self, domain): """ 检查外链 :param domain: 域名 :return: dict - 检测结果 """ try: # 构建查询URL query_url = self.backlink_url.format(domain=domain) headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36' } # 使用curl_cffi模拟浏览器 response = curl_requests.get(query_url, headers=headers, impersonate='chrome', timeout=10) if response.status_code == 200: content = response.text # 检查是否包含敏感词 has_sensitive = self._check_backlink_sensitive(content) # 检查是否有子域名 has_subdomains = '子域名' in content return { 'has_sensitive': has_sensitive, 'has_subdomains': has_subdomains } else: self._log_warning(f"桔子SEO外链查询失败: {response.status_code}") return {'has_sensitive': False, 'has_subdomains': False} except Exception as e: self._handle_exception(e, domain) return {'has_sensitive': False, 'has_subdomains': False} def _extract_history_info(self, content): """ 提取历史信息 :param content: 页面内容 :return: str - 历史信息 """ try: # 这里需要根据实际页面结构调整正则表达式 pattern = r'