| name | mofa-crawler |
| description | Web crawling via Cloudflare Browser Rendering API - full-site extraction with JavaScript rendering, AI structured extraction |
| triggers | ["crawl","็ฌ่ซ","ๆๅ","็ฌๅ็ฝ็ซ","cloudflare crawl"] |
| requires_env | ["CF_API_TOKEN","CF_ACCOUNT_ID"] |
| requires_bins | curl |
| always | false |
MOFA Crawler
Cloudflare Browser Rendering Crawl API ้ๆ โโ ไธ็ซๅผ็ฝ็ซๆๅ่งฃๅณๆนๆกใ
ๅๅ็ฌ่ซ่ตทๅฎถ็ Cloudflare๏ผ่ฝฌๅคดๅๅธไบ็ฌ่ซ APIใ
ๅ
่ดน็๏ผ5 ไปปๅก/ๅคฉ๏ผ100 ้กต/ไปปๅก
ไป่ดน็๏ผ$5/ๆ๏ผ1000 ไปปๅก/ๅคฉ๏ผ1000 ้กต/ไปปๅก
Onboarding / ๅผๅงไฝฟ็จ
ๅ็ฝฎ่ฆๆฑ
-
Cloudflare ่ดฆๅท
-
่ทๅ API Token
- ่ฟๅ
ฅ Cloudflare Dashboard โ My Profile โ API Tokens
- ๅๅปบ Token๏ผๆไบไปฅไธๆ้๏ผ
Account:Browser Rendering:Edit
Zone:Read (ๅฏ้๏ผ็จไบ้ช่ฏๅๅ)
-
่ทๅ Account ID
- ๅจ Cloudflare Dashboard ๅณไพงๆ ๆพๅฐ Account ID
-
้
็ฝฎ็ฏๅขๅ้
export CF_API_TOKEN="your-api-token-here"
export CF_ACCOUNT_ID="your-account-id-here"
-
้ช่ฏ้
็ฝฎ
curl -s "https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/browser-rendering/crawl" \
-H "Authorization: Bearer $CF_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com","limit":1}'
ๅฟซ้ๅผๅง
curl -X POST "https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/browser-rendering/crawl" \
-H "Authorization: Bearer $CF_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"limit": 10
}'
ๆ
้ๆ้ค
| ้ฎ้ข | ่งฃๅณๆนๆก |
|---|
Authentication error | ๆฃๆฅ CF_API_TOKEN ๆฏๅฆๆญฃ็กฎ๏ผๆฏๅฆๆ Browser Rendering ๆ้ |
Account not found | ๆฃๆฅ CF_ACCOUNT_ID ๆฏๅฆๆญฃ็กฎ |
Rate limit exceeded | ๅ
่ดน็ๆฏๅคฉ 5 ไธชไปปๅก๏ผๅ็บงๅฐไป่ดน็ๆ็ญๅพ
็ฌฌไบๅคฉ |
Page limit exceeded | ๅๆฌกไปปๅกๆๅค 1000 ้กต๏ผๅๅฐ limit ๅๆฐ |
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CLOUDFLARE CRAWLER PIPELINE โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
User Request
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Phase 1: ENTRY (Strong Model) โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โข Analyze user intent โ
โ โข Validate target URL โ
โ โข Determine crawl strategy โ
โ - Limit: pages to crawl โ
โ - Format: html | markdown | json โ
โ - JS rendering: true | false โ
โ - AI extraction: field definitions โ
โ - Filters: include/exclude patterns โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Phase 2: DISCOVERY (API Client) โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ Step 1: Submit Crawl Job โ
โ POST /accounts/{id}/browser-rendering/crawl โ
โ โ โ
โ Return: job_id โ
โ โ โ
โ Step 2: Poll Status (async) โ
โ GET /accounts/{id}/browser-rendering/crawl/{job_id} โ
โ โ โ
โ Status: queued โ crawling โ completed | failed โ
โ โ โ
โ Retry on failure (max 3) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Phase 3: ANALYZE (Strong Model) โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โข Parse crawled content โ
โ โข Extract key information โ
โ โข Apply user-defined filters โ
โ โข Validate data quality โ
โ โ
โ Output: Structured content with metadata โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Phase 4: SYNTHESIZE (Output Formatter) โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โข Format based on user request โ
โ - Markdown: clean text for AI/RAG โ
โ - JSON: structured data with AI extraction โ
โ - HTML: raw page content โ
โ โข Generate summary statistics โ
โ โข Save to ./crawl/{domain}/{timestamp}/ โ
โ - content.{md|json|html} โ
โ - summary.md โ
โ - metadata.json โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Quick Start (5 minutes)
TL;DR
cp .env.example .env
export $(cat .env | xargs)
curl -H "Authorization: Bearer $CF_API_TOKEN" \
https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/browser-rendering
Prerequisites
Step 1: Get Account ID
- ็ปๅฝ https://dash.cloudflare.com (ๅ
่ดนๆณจๅ)
- ๆฅ็้กต้ขๅณไพง่พนๆ
- ๆพๅฐ Account ID (32ไฝๅญ็ฌฆไธฒ๏ผๅฆ
1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p)
- ๅคๅถๅค็จ
Step 2: Create API Token
- ็ปๅฝๅ็นๅปๅณไธ่งๅคดๅ โ My Profile
- ้ๆฉ API Tokens ๆ ็ญพ
- ็นๅป Create Token
- ้ๆฉ Custom token ๆจกๆฟ
- ๅกซๅ้
็ฝฎ๏ผ
- Token name:
crawler-token
- Permissions:
- Account โ Browser Rendering โ Edit
- (ๅฏ้) Client IP Address Filtering: ้ๅถไฝ ็IPๆดๅฎๅ
จ
- ็นๅป Continue to summary โ Create Token
- โ ๏ธ ็ซๅณๅคๅถ token๏ผๅชๆพ็คบไธๆฌก๏ผ๏ผ
Step 3: Configure Environment
ๆนๅผ 1: ็ฏๅขๅ้๏ผๆจ่๏ผ
export CF_API_TOKEN="your_api_token_here"
export CF_ACCOUNT_ID="your_account_id_here"
ๆนๅผ 2: .env ๆไปถ
cp .env.example .env
ๆนๅผ 3: ้ช่ฏ้
็ฝฎ
curl -X GET "https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/browser-rendering" \
-H "Authorization: Bearer $CF_API_TOKEN"
่ฟๅ {"success": true} ่กจ็คบๆๅ๏ผ๐
API Reference
Submit Crawl Job
POST https://api.cloudflare.com/client/v4/accounts/{account_id}/browser-rendering/crawl
Request Body:
{
"url": "https://example.com",
"limit": 50,
"formats": ["markdown"],
"render": true,
"includePatterns": ["/docs/**", "/blog/**"],
"excludePatterns": ["/admin/**"],
"modifiedSince": "2024-01-01T00:00:00Z"
}
Poll Job Status
GET https://api.cloudflare.com/client/v4/accounts/{account_id}/browser-rendering/crawl/{job_id}
Response:
{
"success": true,
"result": {
"jobId": "abc123",
"status": "completed",
"pages": [
{
"url": "https://example.com/page1",
"title": "Page Title",
"content": "...markdown content..."
}
]
}
}
Features
1. Full-Site Crawling
Give a starting URL,็ณป็ป่ชๅจๅ็ฐๆๆ้กต้ข๏ผ
POST /crawl
{
"url": "https://docs.example.com",
"limit": 100
}
2. JavaScript Rendering
ๅฏๅจ็ๅฎ Chrome ๆต่งๅจๆธฒๆ้กต้ข๏ผ
{
"url": "https://react-app.com",
"render": true
}
For static sites, set render: false for speed.
3. AI Structured Extraction (JSON + AI)
Use natural language to extract structured data๏ผ
{
"url": "https://ecommerce.com/products",
"formats": ["json"],
"ai": {
"prompt": "Extract product name, price, and description"
}
}
4. Incremental Crawling
ๅช็ฌๆ่ฟๆดๆฐ็้กต้ข๏ผ
{
"url": "https://blog.com",
"modifiedSince": "2024-03-01T00:00:00Z"
}
5. URL Filtering
Include/exclude patterns with wildcards๏ผ
{
"url": "https://site.com",
"includePatterns": ["/docs/**", "/api/**"],
"excludePatterns": ["/docs/legacy/**", "**/*.pdf"]
}
Output Formats
| Format | Use Case | Description |
|---|
| Markdown | AI/RAG pipelines | Clean text, easy to chunk |
| JSON | Data analysis | Structured with AI extraction |
| HTML | Archive/backup | Raw page content |
Pricing & Limits
| Tier | Price | Tasks/Day | Pages/Task | Browser Time |
|---|
| Free | $0 | 5 | 100 | 10 min |
| Paid | $5/month | 1000 | 1000 | 60 min |
Result Retention: 14 days
Max Job Runtime: 7 days
Comparison with Alternatives
| Tool | Price | Setup | JS Rendering | AI Extraction |
|---|
| Cloudflare Crawl | $5/mo | Zero | โ
| โ
|
| Firecrawl | $47/mo | API key | โ
| โ
|
| Crawl4AI | Free | Self-hosted | โ
| โ |
| Jina Reader | Free | API key | โ | โ |
Use Cases
RAG Pipeline Data Ingestion
POST /crawl
{
"url": "https://docs.framework.com",
"limit": 500,
"formats": ["markdown"],
"includePatterns": ["/docs/**"]
}
Competitor Content Analysis
POST /crawl
{
"url": "https://competitor.com/products",
"formats": ["json"],
"ai": {
"prompt": "Extract product name, price, description, rating"
}
}
CMS Migration
POST /crawl
{
"url": "https://old-blog.com",
"formats": ["markdown"],
"limit": 1000
}
Error Handling
| Error | Reason | Solution |
|---|
| 401 | Invalid API token | Check CF_API_TOKEN |
| 403 | Account not enabled | Enable Browser Rendering |
| 429 | Rate limit | Wait or upgrade plan |
| 500 | Crawl failed | Retry with smaller limit |
Limitations
- โ ๏ธ No screenshots (use /screenshot endpoint separately)
- โ ๏ธ Can't bypass bot protection (by design)
- โ ๏ธ Respects robots.txt
- โ ๏ธ Free tier very limited for serious use
Safety & Ethics
- Always check target site's robots.txt
- Respect rate limits
- Don't crawl private/authenticated content without permission
- Consider content ownership and copyright
Output Directory Structure
./crawl/
โโโ {domain}/
โโโ {timestamp}/
โโโ content.md # Main content
โโโ content.json # Structured data
โโโ summary.md # Crawl summary
โโโ metadata.json # Job metadata
โโโ pages/ # Individual pages
โโโ index.md
โโโ about.md
โโโ ...