# 网页内容提取器
## 基本信息
- Slug: `tolik-unicornrider-mcp_scraper`
- Source: modelscope
- Publisher: @tolik-unicornrider/mcp_scraper
- Categories: browser-automation / developer-tools
- Hosted: No
- License: Unknown
- Source URL: https://www.modelscope.cn/mcp/servers/@tolik-unicornrider/mcp_scraper
## 简介
一个从网站提取有意义内容并将HTML转换为高质量Markdown的MCP服务器，使用Mozilla的Readability引擎。
## 安装提示

```bash
# Install dependencies npm install # Build the project npm run build # Optionally, install globally npm install -g .
```

## MCP Server 详情

# 网站抓取工具

一个用于抓取网站并将 HTML 转换为 Markdown 的命令行工具和 MCP 服务器。

## 特性

- 使用 Mozilla 的 [Readability](https://github.com/mozilla/readability) 库（与 Firefox 的阅读视图使用的引擎相同）从网页中提取有意义的内容
- 使用 TurndownService 将干净的 HTML 转换为高质量的 Markdown
- 通过移除潜在有害的脚本标签来安全处理 HTML
- 既可以作为命令行工具使用，也可以作为 MCP 服务器运行
- 支持直接将本地 HTML 文件转换为 Markdown

## 安装

```bash
# Install dependencies
npm install

# Build the project
npm run build

# Optionally, install globally
npm install -g .
```


## 使用方法

### 命令行模式

```bash
# Print output to console
scrape https://example.com

# Save output to a file
scrape https://example.com output.md

# Convert a local HTML file to Markdown
scrape --html-file input.html

# Convert a local HTML file and save output to a file
scrape --html-file input.html output.md

# Show help
scrape --help

# Or run via npm script
npm run start:cli -- https://example.com
```


### MCP 服务器模式

此工具可以用作 Model Context Protocol (MCP) 服务器：

```bash
# Start in MCP server mode
npm start
```


## 代码结构

- `src/index.ts` - 核心功能和 MCP 服务器实现
- `src/cli.ts` - 命令行界面实现
- `src/data_processing.ts` - HTML 到 Markdown 的转换功能

## API

该工具导出以下函数：

```typescript
// Scrape a website and convert to Markdown
import { scrapeToMarkdown } from './build/index.js';

// Convert HTML string to Markdown directly
import { htmlToMarkdown } from './build/data_processing.js';

async function example() {
  // Web scraping
  const markdown = await scrapeToMarkdown('https://example.com');
  console.log(markdown);
  
  // Direct HTML conversion
  const html = '<h1>Hello World</h1><p>This is <strong>bold</strong> text.</p>';
  const md = htmlToMarkdown(html);
  console.log(md);
}
```


## 许可证

ISC

