MCP足球比赛⚽
Python中的MCP(Model Context Protocol)服务器,用于从多个来源通过智能Web抓取获取足球比赛数据。
🌟 特点
- 🏈 多个来源:从ESPN、goal.com、BBC Sport、Marca、AS等中提取数据
- 🔄 可配置的URL:易于修改和添加新字体
- 📊 结构化JSON输出:为IA处理优化的格式
- 🚀 兼容MCP:与Claude和其他人工智能系统直接集成
- ⚡ 异步抓取:通过并行请求优化性能
- 🏆 智能检测:自动识别“有吸引力”的比赛和大型球队
- 🎯 高级过滤:评分系统,以优先考虑重要比赛
- 💾 缓存系统:埃维塔要求收件
📊 提取的数据
- 团队:当地团队和游客的全名
- 时间表:比赛的确切日期和时间
- 链接:比赛、锦标赛或联赛(冠军、英超等)
- 运河:广播的电视/流媒体频道
- 体育场:播放的地方(如果可用)
- 埃斯塔多:计划,现场,完成
- 标记:实时结果(可用时)
- 吸引力水平:根据球队和联赛的重要性得分1-5
🚀 快速安装
选项1:使用紫外线(推荐)
# Instalar uv si no lo tienes
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
# Clonar e instalar
git clone
cd mcp-partidos
uv venv
uv pip install -r requirements.txt选项2:使用传统PIP
git clone
cd mcp-partidos
pip install -r requirements.txt⚙️ 配置
1.配置字体
编辑 src/mcp_partidos/config.py 添加或修改字体:
FUENTES_PARTIDOS = [
"https://www.espn.com/soccer/fixtures",
"https://www.goal.com/fixtures",
"https://www.bbc.com/sport/football/fixtures",
"https://www.marca.com/futbol/fixture.html",
# Agrega más fuentes aquí
]2. 设置重要设备
为评分系统定制“大型”设备列表:
EQUIPOS_GRANDES = [
"Real Madrid", "Barcelona", "Manchester United",
"Liverpool", "Bayern Munich", "PSG",
# Agrega más equipos aquí
]🎮 使用
作为MCP服务器(与克劳德)
- 配置为
claude_desktop_config.json:
{
"mcpServers": {
"mcp-partidos": {
"command": "uv",
"args": ["run", "--directory", "/ruta/a/mcp-partidos", "python", "run_server.py"]
}
}
}- 克劳德:
"Obtén los partidos de fútbol de hoy y muéstrame los 5 más atractivos ordenados por importancia"作为独立脚本
# Ejecutar servidor MCP
python run_server.py
# Probar el scraper
python test_scraper.py
# Probar una fuente específica
python test_scraper.py "https://www.espn.com/soccer/fixtures"🛠️ 可用的MCP工具
| 工具 | 描述 | 参数 |
|---|---|---|
obtener_partidos_hoy | 获得今天安排的比赛 | incluir_fuentes (bool) |
obtener_partidos_fecha | 获取特定日期的匹配项 | fecha (YYYY-MM-DD), incluir_fuentes (bool) |
listar_fuentes | 列出所有配置的字体 | - |
probar_fuente | 验证源是否有效 | url (字符串) |
📋 JSON输出格式
{
"partidos": [
{
"equipo_local": "Barcelona",
"equipo_visitante": "Real Madrid",
"fecha": "2025-09-19",
"hora": "15:00",
"liga": "La Liga",
"canales": ["ESPN", "Movistar+"],
"estadio": "Camp Nou",
"estado": "programado",
"fuente": {
"nombre": "espn.com",
"url": "https://www.espn.com/soccer/fixtures"
},
"metadatos": {
"es_partido_importante": true,
"nivel_atractivo": 5,
"fecha_extraccion": "2025-09-19T10:30:00Z"
}
}
],
"fecha_consulta": "2025-09-19",
"total_partidos": 15,
"fuentes_consultadas": 6,
"timestamp": "2025-09-19T10:30:00Z",
"estadisticas": {
"por_liga": {
"Champions League": 4,
"Premier League": 6,
"La Liga": 5
},
"partidos_importantes": 8,
"nivel_atractivo_promedio": 3.2
}
}🎯 与Claude一起使用的示例
# Partidos de hoy con análisis
"Obtén los partidos de fútbol de hoy, ordénalos por atractivo y dime cuáles son los 3 mejores para ver"
# Partidos por fecha
"¿Qué partidos hay el 2025-12-25? Muéstrame solo los de ligas europeas importantes"
# Análisis de fuentes
"Lista las fuentes configuradas y prueba ESPN para ver si funciona bien"
# Partidos por horario
"Obtén partidos de hoy y agrúpalos por franja horaria, mostrando horarios en UTC-5"
# Análisis por liga
"Dame partidos de hoy y dime cuántos hay por liga, priorizando Champions League"🔧 开发和测试
# Instalar dependencias de desarrollo
uv pip install -e ".[dev]"
# Formatear código
uv run black src/
# Verificar tipos con mypy
uv run mypy src/
# Probar scraper completo
uv run python test_scraper.py
# Probar fuente específica
uv run python test_scraper.py "https://www.espn.com/soccer/fixtures"
# Ejecutar servidor MCP
uv run python run_server.py📁 项目结构
mcp-partidos/
├── src/
│ └── mcp_partidos/
│ ├── __init__.py
│ ├── server.py # Servidor MCP principal
│ ├── scraper.py # Lógica de web scraping
│ ├── config.py # Configuración de URLs y equipos
│ └── models.py # Modelos de datos (Partido, etc.)
├── run_server.py # Script para ejecutar el servidor
├── test_scraper.py # Script de prueba del scraper
├── claude_config.md # Guía de configuración para Claude
├── install.sh # Script de instalación con uv
├── pyproject.toml # Configuración del proyecto
├── requirements.txt # Dependencias Python
└── README.md # Este archivo🌐 支持的来源
- 娱乐与体育节目电视网 -全面国际覆盖
- 西汉姆联 -全球新闻和固定装置
- 英国广播公司体育 -英国和欧洲体育
- 品牌 -专注于西班牙和欧洲足球
- 作为 -西班牙语体育
- 天空体育 -英超和欧洲足球
- 欧洲足球协会联盟 -欧洲官方比赛
*通过将URL添加到 config.py*
🤝 争议
- 叉库
- 为您的功能创建分支:
git checkout -b feature/nueva-fuente - 将新字体添加到
config.py - 测试匹配
python test_scraper.py - 承诺推动:
git commit -am 'Agregar fuente XYZ' - Crea取消拉取请求
📄 许可证
麻省理工学院许可证-可自由用于个人和商业项目。
🆘 支撑
如果您遇到问题:
- 检查来源:网页经常更改
- 测试个人来源:
python test_scraper.py - 验证连接:一些消息来源可能会阻止某些IP
- 更新选择器编辑:
config.py如果一个喷泉改变了它的结构
______________________________________________________________________
⭐ 如果你觉得有用,就给他一颗星! ⭐
