后端变更: - 移除 tasks_manager.py 和 core/auth.py,简化架构 - 新增 core/scheduler.py 验证调度器,替代原有任务管理 - 大幅优化 api_server.py:统一错误处理、增强参数验证、支持调度器控制 - validator.py 增强 SOCKS4/SOCKS5 代理验证支持 - config.py 清理废弃配置(WebSocket、API Key、认证开关) - SQLite 数据库操作性能优化 前端变更: - 移除任务管理页面 (CrawlerTasks) 和 WebSocket 相关代码 - 路由简化为 4 个核心页面:总览、代理列表、插件管理、设置 - 提取前端工具函数(clipboard、confirm、format)和 API 类型定义 - 优化 CSS 架构:完善 variables、utilities、element-plus 样式 - Dashboard、Plugins、ProxyList、Settings 页面 UI/UX 优化 - App.vue 响应式侧边栏和页面过渡动画优化 其他: - 移除 PowerShell 启动脚本,简化 Windows 批处理脚本 - 新增 README_SOCKS.md SOCKS 代理支持文档 - .env.example 和 .gitignore 更新
76 lines
2.3 KiB
Python
76 lines
2.3 KiB
Python
import sys
|
|
import os
|
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from core.crawler import BasePlugin
|
|
from core.log import logger
|
|
import asyncio
|
|
|
|
class ProxyListDownloadPlugin(BasePlugin):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.name = "ProxyListDownload"
|
|
self.urls = [
|
|
"https://www.proxy-list.download/api/v1/get?type=http",
|
|
"https://www.proxy-list.download/api/v1/get?type=https",
|
|
"https://www.proxy-list.download/api/v1/get?type=socks4",
|
|
"https://www.proxy-list.download/api/v1/get?type=socks5"
|
|
]
|
|
|
|
async def parse(self, html):
|
|
if not html:
|
|
return
|
|
|
|
lines = html.split('\r\n')
|
|
if len(lines) <= 1:
|
|
lines = html.split('\n')
|
|
|
|
count = 0
|
|
# 根据 URL 判断协议类型
|
|
if 'type=socks4' in self.current_url:
|
|
protocol = 'socks4'
|
|
elif 'type=socks5' in self.current_url:
|
|
protocol = 'socks5'
|
|
elif 'type=https' in self.current_url:
|
|
protocol = 'https'
|
|
else:
|
|
protocol = 'http'
|
|
|
|
for line in lines:
|
|
line = line.strip()
|
|
if not line:
|
|
continue
|
|
|
|
if ':' in line:
|
|
parts = line.split(':')
|
|
if len(parts) >= 2:
|
|
ip = parts[0]
|
|
port = parts[1]
|
|
yield ip, int(port), protocol
|
|
count += 1
|
|
|
|
if count > 0:
|
|
logger.info(f"{self.name} 解析完成,从 {self.current_url} 获得 {count} 个潜在代理")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
async def test_plugin():
|
|
plugin = ProxyListDownloadPlugin()
|
|
print(f"========== 测试 {plugin.name} ==========")
|
|
print(f"目标URL数量: {len(plugin.urls)}")
|
|
print(f"开始抓取...\n")
|
|
|
|
proxies = await plugin.run()
|
|
|
|
print(f"\n========== 抓取结果 ==========")
|
|
print(f"总计获取 {len(proxies)} 个代理:")
|
|
print("-" * 60)
|
|
|
|
for idx, (ip, port, protocol) in enumerate(proxies, 1):
|
|
print(f"{idx:3d}. {ip:15s} : {str(port):5s} | {protocol}")
|
|
|
|
print("-" * 60)
|
|
print(f"完成!共 {len(proxies)} 个代理~")
|
|
|
|
asyncio.run(test_plugin())
|