🚀 多功能文档处理服务

基于 Cloudflare Browser Rendering 的一站式文档处理平台

🌟 功能特性

📖 使用方法

📸 网页截图功能

高质量网页截图,支持多种自定义选项:

1. 基础截图

GET /screenshot?url=https://example.com&format=png

或者:

POST /screenshot
Content-Type: application/json
X-API-Key: your_api_key

{
  "url": "https://example.com",
  "format": "png",
  "fullPage": true
}

2. 高级截图选项

POST /screenshot
Content-Type: application/json

{
  "url": "https://example.com",
  "format": "jpeg",
  "quality": 90,
  "viewport": {"width": 1920, "height": 1080},
  "fullPage": false,
  "omitBackground": true,
  "clip": {"x": 0, "y": 0, "width": 800, "height": 600}
}

3. 自定义样式和脚本

POST /screenshot
Content-Type: application/json

{
  "url": "https://example.com",
  "addStyleTag": [
    {"content": "body { background: #f0f0f0; }"}
  ],
  "addScriptTag": [
    {"content": "document.querySelector('h1').style.color = 'red';"}
  ]
}

🕷️ 网页爬取功能

抓取网页内容并转换为不同格式:

1. 获取网页 JSON 数据

GET /crawl?url=https://example.com&format=json

或者:

POST /crawl
Content-Type: application/json
X-API-Key: your_api_key

{
  "url": "https://example.com",
  "format": "json"
}

2. 提取网页为 Markdown

GET /crawl?url=https://example.com&format=markdown

或者:

POST /crawl
Content-Type: application/json

{
  "url": "https://example.com",
  "format": "markdown",
  "options": {
    "timeout": 30000,
    "waitTime": 2000
  }
}

3. 直接转换网页为 PDF

GET /crawl?url=https://example.com&format=pdf

或者:

POST /crawl
Content-Type: application/json

{
  "url": "https://example.com",
  "format": "pdf"
}

📝 Markdown 转 PDF 功能

API 密钥认证

如果服务配置了 API 密钥,需要在请求中包含认证信息:

# 方式 1: 请求头
X-API-Key: your_api_key

# 方式 2: Bearer Token
Authorization: Bearer your_api_key

# 方式 3: 查询参数
?api_key=your_api_key

1. GET 请求

GET /pdf?markdown=# Hello World%0A%0AThis is a **test** document.&title=My Document&api_key=your_key

或者:

GET /?markdown=# Hello World&title=My Document

2. POST 请求 (JSON)

POST /pdf
Content-Type: application/json
X-API-Key: your_api_key

{
  "markdown": "# Hello World\n\nThis is a **test**.",
  "title": "My Document"
}

3. POST 请求 (纯文本)

POST /pdf
Content-Type: text/plain
Authorization: Bearer your_api_key

# Hello World

This is a **test** document.

🧪 示例

Markdown 转 PDF 示例

点击生成示例 PDF

网页截图示例

截图 example.com (PNG)

截图 example.com (全页面 JPEG)

网页爬取示例

抓取 example.com (JSON)

抓取 example.com (Markdown)

抓取 example.com (PDF)

源码

GitHub Repository