The Web Scraper MCP Server is a comprehensive TypeScript web scraping tool that extracts, processes, and manages web content efficiently.
Core Scraping Capabilities:
- Scrape single web pages or batch process multiple URLs simultaneously
- Export content in multiple formats: Markdown, Text, HTML, or JSON
- Handle dynamic Single Page Applications (SPAs) using Puppeteer headless browsing
- Extract images and text content, saving them locally
- Smart content extraction that automatically detects main page content
Advanced Features:
- Define custom rule sets or use built-in ones (blog, news) to extract specific page elements using CSS selectors
- Set custom domain-specific HTTP headers to bypass login restrictions or handle authentication
- Monitor scraping operation status in real-time
Data Management:
- List information about previously downloaded files (images and text)
- Clean up and delete scraped files when needed
- Organize and manage all scraped data efficiently
Leverages Git for version control, enabling users to clone and manage the web scraper codebase.
Enables export of web content as Markdown, converting HTML to a readable format with preserved headings, links, and images.
Uses npm for package management, allowing easy installation and dependency management for the web scraper.
Utilizes Puppeteer headless browser to render JavaScript-heavy websites and single-page applications (SPAs) for complete content extraction.
Built with TypeScript, providing type-safe web scraping capabilities with custom rule sets and domain-specific headers.
Web Scraper MCP Server
基于 Model Context Protocol (MCP) 的 TypeScript 网页爬取服务器,内置多种常用爬取与命令工具。
功能特性
- 🚀 多种导出格式: 支持将爬取内容导出为 Markdown、Text、HTML ��� JSON 格式
- 🎭 Puppeteer 无头浏览器: 解决未实现静态化的 SPA 单页应用渲染问题
- 📋 规则集支持: 支持设置规则集,实现抓取网页的特定部分内容
- 🔧 自定义域名 Headers: 支持设置自定义域名 Headers,绕过网站登录限制
- 📦 批量爬取: 支持同时爬取多个 URL
- 🎯 智能内容提取: 自动识别和提取网页主要内容
安装
使用方法
启动服务器
可用工具
1. scrape_url - 爬取单个网页
参数说明:
url
(必需): 要爬取的网页 URLformat
(可选): 导出格式,支持markdown
、text
、html
、json
,默认为markdown
usePuppeteer
(可选): 是否使用 Puppeteer 无头浏览器,默认为false
ruleSet
(可选): 规则集名称,用于提取特定内容customHeaders
(可选): 自定义请求头
2. create_rule_set - 创建内容提取规则集
参数说明:
name
(必需): 规则集名称rules
(必需): 提取规则配置title
: 标题选择器content
: 内容选择器links
: 链接选择器images
: 图片选择器exclude
: 要排除的选择器列表
3. set_domain_headers - 设置域名请求头
4. batch_scrape - 批量爬取
预定义规则集
系统内置了以下规则集:
- blog: 适用于大多数博客文章页面
- news: 适用于新闻网站文章
- product: 适用于电商产品页面
- documentation: 适用于技术文档页面
- forum: 适用于论坛帖子页面
导出格式
Markdown
将网页内容转换为 Markdown 格式,包含标题、内容、链接和图片。
Text
纯文本格式,去除所有 HTML 标签。
HTML
清理后的 HTML 格式,移除脚本和样式。
JSON
完整的结构化数据,包含所有提取的信息。
开发
项目结构
开发模式
测试
配置
环境变量
LOG_LEVEL
: 日志级别 (debug, info, warn, error)PUPPETEER_TIMEOUT
: Puppeteer 超时时间(毫秒)REQUEST_TIMEOUT
: HTTP 请求超时时间(毫秒)
自定义配置
可以通过修改源代码来自定义:
- 默认请求头: 编辑
src/headers/headerManager.ts
- 预定义规则集: 编辑
src/rules/ruleEngine.ts
- 导出格式: 编辑
src/export/exportManager.ts
常见问题
Q: 为什么某些网站爬取失败?
A: 可能是因为网站有反爬虫机制。尝试:
- 使用
usePuppeteer: true
启用无头浏览器 - 设置合适的自定义请求头
- 使用预定义的反检测请求头
Q: 如何处理需要登录的网站?
A: 使用 set_domain_headers
工具设置包含认证信息的请求头,如 Cookie 或 Authorization。
Q: SPA 应用内容为空怎么办?
A: 设置 usePuppeteer: true
使用 Puppeteer 渲染动态内容。
许可证
MIT License
贡献
欢迎提交 Issue 和 Pull Request!
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
A TypeScript-based web scraping server built on the Model Context Protocol that offers multiple export formats, content extraction rules, and support for both static and dynamic (SPA) websites.
Related MCP Servers
- AsecurityAlicenseAqualityA TypeScript-based MCP server utilizing the UseScraper API to provide web scraping capabilities, allowing users to extract content from webpages in various formats.Last updated -12JavaScriptMIT License
- AsecurityAlicenseAqualityA production-ready Model Context Protocol server that enables language models to leverage AI-powered web scraping capabilities, offering tools for transforming webpages to markdown, extracting structured data, and executing AI-powered web searches.Last updated -536PythonMIT License
- -securityAlicense-qualityA Model Context Protocol server that allows LLMs to interact with web content through standardized tools, currently supporting web scraping functionality.Last updated -PythonMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server enabling AI assistants to scrape web content with high accuracy and flexibility, supporting multiple scraping modes and content formatting options.Last updated -46162TypeScriptMIT License