cloudflare-markdown
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCloudflare Markdown Rendering
Cloudflare Markdown 渲染
Renders web pages or raw HTML content to Markdown using Cloudflare Browser Rendering API.
借助Cloudflare Browser Rendering API将网页或原始HTML内容转换为Markdown格式。
Usage
使用方法
Convert a URL to Markdown:
bash
bash render.bash --url "https://example.com"Convert raw HTML to Markdown:
bash
bash render.bash --html "<div>Hello World</div>"将URL转换为Markdown:
bash
bash render.bash --url "https://example.com"将原始HTML转换为Markdown:
bash
bash render.bash --html "<div>Hello World</div>"Options
选项
| Option | Description |
|---|---|
| URL to fetch and convert to Markdown |
| Raw HTML content to convert to Markdown |
| Page load behavior: |
| Reject request patterns (regex, can be specified multiple times) |
| Custom user agent string |
| Show help message |
| 选项 | 说明 |
|---|---|
| 要抓取并转换为Markdown的URL |
| 要转换为Markdown的原始HTML内容 |
| 页面加载行为: |
| 要拒绝的请求模式(正则表达式,可多次指定) |
| 自定义用户代理字符串 |
| 显示帮助信息 |
Examples
示例
Basic URL conversion
基础URL转换
bash
bash render.bash --url "https://developers.cloudflare.com/"bash
bash render.bash --url "https://developers.cloudflare.com/"JavaScript-heavy pages
含大量JavaScript的页面
For SPAs or JS-heavy pages, use or :
networkidle0networkidle2bash
bash render.bash --url "https://spa-example.com" --wait-until networkidle0对于单页应用(SPA)或含大量JavaScript的页面,使用或:
networkidle0networkidle2bash
bash render.bash --url "https://spa-example.com" --wait-until networkidle0Exclude CSS requests
排除CSS请求
bash
bash render.bash --url "https://example.com" --reject '/^.*\.(css)/'bash
bash render.bash --url "https://example.com" --reject '/^.*\.(css)/'Custom user agent
自定义用户代理
bash
bash render.bash --url "https://example.com" --user-agent "Mozilla/5.0 (compatible; MyBot/1.0)"bash
bash render.bash --url "https://example.com" --user-agent "Mozilla/5.0 (compatible; MyBot/1.0)"Credentials
凭证
Credentials are retrieved from macOS Keychain:
- - Cloudflare account ID
CLOUDFLARE_ACCOUNT_ID - - Cloudflare API token with Browser Rendering permissions
CLOUDFLARE_MARKDOWN_API_KEY
To store credentials:
bash
security add-generic-password -s CLOUDFLARE_ACCOUNT_ID -a CLOUDFLARE_ACCOUNT_ID -w "your-account-id"
security add-generic-password -s CLOUDFLARE_MARKDOWN_API_KEY -a CLOUDFLARE_MARKDOWN_API_KEY -w "your-api-token"凭证从macOS钥匙串中获取:
- - Cloudflare账户ID
CLOUDFLARE_ACCOUNT_ID - - 拥有Browser Rendering权限的Cloudflare API令牌
CLOUDFLARE_MARKDOWN_API_KEY
存储凭证的方法:
bash
security add-generic-password -s CLOUDFLARE_ACCOUNT_ID -a CLOUDFLARE_ACCOUNT_ID -w "your-account-id"
security add-generic-password -s CLOUDFLARE_MARKDOWN_API_KEY -a CLOUDFLARE_MARKDOWN_API_KEY -w "your-api-token"Output
输出
Returns JSON response from Cloudflare API:
json
{
"success": true,
"result": "# Example Domain\n\nThis domain is for use in illustrative examples..."
}返回来自Cloudflare API的JSON响应:
json
{
"success": true,
"result": "# Example Domain\n\nThis domain is for use in illustrative examples..."
}Requirements
依赖要求
- for JSON processing
jq - for HTTP requests
curl - macOS Keychain with stored credentials
- 用于JSON处理
jq - 用于HTTP请求
curl - 已存储凭证的macOS钥匙串