Files
ProxyPool/app/plugins/fate0.py
祀梦 f09a8e16c4 fix: 修复爬虫网络层、验证队列卡死及 API 500 错误
- 修复 BaseHTTPPlugin 连接池、并发控制、异常日志、超时策略
- 修复/增强 8 个爬虫插件的稳定性和 fallback 机制
- 清理 validation_tasks 表 4 万+ pending 任务,避免队列卡死
- 修复 app/api/main.py 缺失全局 app 实例导致的 500 错误
- 提升前端 Axios 超时到 120 秒,避免请求断开
- 修复插件统计持久化和调度器生命周期问题
2026-04-04 19:27:36 +08:00

47 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import json
from typing import List
from app.core.plugin_system import ProxyRaw
from app.plugins.base import BaseHTTPPlugin
from app.core.log import logger
class Fate0Plugin(BaseHTTPPlugin):
default_config = {"max_pages": 5}
name = "fate0"
display_name = "Fate0聚合站"
description = "来自 GitHub 持续更新的高质量代理聚合列表"
def __init__(self):
super().__init__()
self.urls = [
"https://raw.githubusercontent.com/fate0/proxylist/master/proxy.list",
"https://cdn.jsdelivr.net/gh/fate0/proxylist@master/proxy.list",
]
async def crawl(self) -> List[ProxyRaw]:
results = []
# 顺序 fetch带 fallback
for url in self.urls:
html = await self.fetch(url, timeout=30)
if html:
break
if not html:
logger.warning(f"{self.display_name} 所有源均不可用")
return results
for line in html.split("\n"):
line = line.strip()
if not line:
continue
try:
data = json.loads(line)
ip = data.get("host")
port = data.get("port")
protocol = data.get("type", "http")
if ip and port:
results.append(ProxyRaw(ip, int(port), protocol))
except Exception:
continue
if results:
logger.info(f"{self.display_name} 解析完成,获取 {len(results)} 个潜在代理")
return results