站点爬虫MCP
一个强大的模型上下文协议(MCP)服务器,用于抓取网站并提取包括图像和SEO元数据在内的资产。专为电子商务网站和一般网络爬行需求而构建。
特性
- 全面的网站分析:12种不同的提取模式,用于完整的网站洞察
- 多模式爬行:一次性提取多种数据类型
- 智能提取:用于精确数据提取的高级模式匹配
- 性能优化:具有速率限制的并发爬行
- 证券分析:HTTPS、安全标头、SSL/TLS信息
- SEO分析:完整的SEO审计,包括元标签、结构化数据等
- 法律遵循:KVKK、GDPR、隐私政策检测
- 商业智能:品牌信息、推荐信、联系方式提取
安装
来自PyPI(发布时)
pip install site-crawler-mcp来源(发展)
使用紫外线(推荐)
# Clone the repository
git clone https://github.com/AndacGuven/site-crawler-mcp.git
cd site-crawler-mcp
# Create virtual environment with Python 3.12
uv venv --python 3.12
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies and package
uv sync使用pip
# Clone the repository
git clone https://github.com/AndacGuven/site-crawler-mcp.git
cd site-crawler-mcp
# Create virtual environment (recommended)
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On Linux/Mac:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Install package in development mode
pip install -e .用法
作为MCP服务器
添加到MCP配置文件中:
- 视窗:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
使用uvx(推荐)
{
"mcpServers": {
"site-crawler": {
"command": "uvx",
"args": ["--from", "/path/to/site-crawler-mcp", "site-crawler-mcp"]
}
}
}使用紫外线跑步
{
"mcpServers": {
"site-crawler": {
"command": "uv",
"args": ["run", "site_crawler"],
"cwd": "/path/to/site-crawler-mcp"
}
}
}直接使用python
{
"mcpServers": {
"site-crawler": {
"command": "python",
"args": ["-m", "site_crawler.server"],
"cwd": "/path/to/site-crawler-mcp/src",
"env": {
"PYTHONPATH": "/path/to/site-crawler-mcp/src"
}
}
}
}备注:替换 /path/to/site-crawler-mcp 根据您的实际项目路径。在Windows上使用反斜杠和驱动器号(例如。, C:\\Users\\YourName\\site-crawler-mcp).
可用工具
site_crawlAssets
抓取网站并根据指定模式提取各种资产。
参数:
url(字符串,必填):开始爬网的URLmodes(array,必填):提取模式数组(见下文)depth(数字,可选):爬行深度(默认值:1)max_pages(数字,可选):要抓取的最大页面数(默认值:50)
可用模式:
images:提取所有带有元数据的图像(alt文本、尺寸、格式)meta:基本SEO元数据(标题、描述、H1标签)brand:公司品牌信息(徽标、名称、关于页面)seo:全面的SEO分析(元标签、结构化数据、开放图)performance:页面加载指标和性能指标security:安全标头和HTTPS配置compliance:可访问性和监管合规性检查infrastructure:服务器技术和CDN检测legal:隐私政策、条款、KVKK合规性careers:工作机会和职业页面references:客户评价和案例研究contact:联系方式(电子邮件、电话、社交媒体、地址)
请求示例:
- 基本图像提取:
{
"tool": "site_crawlAssets",
"arguments": {
"url": "https://example.com",
"modes": ["images"],
"depth": 1
}
}- 全面的SEO和安全审计:
{
"tool": "site_crawlAssets",
"arguments": {
"url": "https://example.com",
"modes": ["seo", "security", "performance"],
"depth": 2
}
}- 商业情报收集:
{
"tool": "site_crawlAssets",
"arguments": {
"url": "https://example.com",
"modes": ["brand", "contact", "references", "careers"],
"depth": 3
}
}- 法律合规性检查:
{
"tool": "site_crawlAssets",
"arguments": {
"url": "https://example.com",
"modes": ["legal", "compliance"],
"depth": 2
}
}发展
需求
- Python 3.10+
- 美丽的Soup4
- 意图tp
- MCP-SDK
- uv(建议开发)
设置开发环境
使用紫外线(推荐)
# Clone the repository
git clone https://github.com/AndacGuven/site-crawler-mcp.git
cd site-crawler-mcp
# Create virtual environment with Python 3.12
uv venv --python 3.12
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies and package
uv sync使用pip
# Clone the repository
git clone https://github.com/AndacGuven/site-crawler-mcp.git
cd site-crawler-mcp
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Install in development mode
pip install -e .运行服务器
使用紫外线
# Run the MCP server
uv run site_crawler
# or
uv run site-crawler-mcp
# or
uv run python -m site_crawler.server直接使用python
python -m site_crawler.server运行测试
# Using uv
uv run pytest tests/
# Using pip
pytest tests/项目结构
site-crawler-mcp/
├── README.md
├── requirements.txt
├── pyproject.toml
├── src/
│ └── site_crawler/
│ ├── __init__.py
│ ├── server.py
│ ├── crawler.py
│ └── utils.py
└── tests/
├── __init__.py
└── test_crawler.py配置
环境变量
CRAWLER_MAX_CONCURRENT:最大并发请求数(默认值:5)CRAWLER_TIMEOUT:请求超时(秒)(默认值:30)CRAWLER_USER_AGENT:自定义用户代理字符串
速率限制
爬虫尊重 robots.txt 并实现礼貌爬行:
- 对同一域的请求之间存在1-2秒的延迟
- 最多5个并发请求
- 指数回退自动重试
用例
电子商务分析
提取产品图片、定价和品牌信息:
"Analyze the e-commerce site example.com for product images, brand info, and contact details"SEO和绩效审计
全面的SEO和性能分析:
"Perform a full SEO audit of example.com including performance metrics and structured data"安全评估
检查安全标头和HTTPS配置:
"Analyze the security posture of example.com including headers and SSL configuration"法律合规检查
验证KVKK/GDP合规性和隐私政策:
"Check example.com for KVKK compliance, privacy policies, and data protection measures"商业智能
收集公司信息和推荐信:
"Extract business information from example.com including company details, references, and career opportunities"联系人信息提取
查找所有联系方式:
"Find all contact information on example.com including emails, phones, social media, and addresses"性能注意事项
- 默认情况下,小于50KB的图像会被过滤掉
- 同时爬行限制为5页
- 大型网站的内存高效流媒体
- URL的自动重复数据删除
错误处理
爬虫可以优雅地处理各种错误情况:
- 网络超时
- URL无效
- 速率限制(429个响应)
- JavaScript繁重的网站(优雅降级)
- 内存限制
贡献
欢迎投稿!请阅读我们的 贡献指南 有关我们的行为准则和提交pull请求流程的详细信息。
许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
致谢
- 内置于 MCP-SDK
- 受到对更好的电子商务爬行工具需求的启发
- 感谢开源社区
支持
有关问题和功能请求,请使用 .
