创建任务
本指南将引导您在 FourA Dashboard 中创建 API key 并发送第一个 request。
第一步:打开 Dashboard
访问 Dashboard 并登录您的 FourA 账号。
第二步:创建 API key
进入 API Keys 页面并点击 Create Key。
为 key 命名以便识别(例如 "production-scraper" 或 "dev-testing")。确认对话框会显示明文 key 及复制按钮。
如果您未及时保存,可以稍后点击 key 所在行的眼睛图标再次查看。在查看功能发布前创建的旧版 key 无法找回,请重新生成。完整流程请见:Managing API Keys。
您的 key 类似于:pk_live_a1b2c3d4e5f6...
第三步:选择 endpoint
FourA 针对不同场景提供四个 endpoint:
Auto (POST /api/auto/)
智能默认选项。传入 URL 和 validate 规则,FourA 将选择最经济的有效路径:直接 request、轮换 proxy 或完整浏览器。最适合不确定需求的新目标网站。
Single (POST /api/single/)
发送快速的 HTTP request。最适合静态 HTML 页面和 API endpoint。Response 时间:通常在 2 秒以内。
Browser (POST /api/browser/)
运行 Chrome 浏览器实例以渲染 JavaScript。最适合单页应用(SPA)、延迟加载内容及需要执行 JS 的页面。Response 时间:2 到 10 秒。
Proxy (POST /api/proxy/)
通过自动重试的轮换 proxy 路由 request。最适合具有机器人检测或受地理限制内容的网站。
第四步:发送第一个 request
打开终端并运行:
curl -X POST https://eu.api.foura.ai/api/single/ \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"method": "GET", "url": "https://example.com"}'
第五步:读取 response
{
"status": 200,
"headers": [
{
"result": { "version": "HTTP/2", "code": 200, "reason": "" },
"content-type": "text/html; charset=UTF-8",
"content-length": "1256"
}
],
"data": "<html>...</html>",
"total_time": 0.45
}
headers 字段是对象数组,每次重定向跳转对应一个对象。每个条目包含一个 result,记录状态行及目标返回的每个 response header。
关键字段:
- status:目标网站的 HTTP 状态码
- data:response 主体(HTML、JSON 或纯文本)
- total_time:request 耗时(秒)
第六步:尝试 Browser request
如果目标页面使用 JavaScript 渲染内容,请改用 browser endpoint:
curl -X POST https://eu.api.foura.ai/api/browser/ \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/products", "timeout_ms": 15000}'
Browser response 使用 body 而非 data:
{
"status": 200,
"headers": {"content-type": "text/html"},
"body": "<html>...</html>"
}
常见问题
| 问题 | 解决方案 |
|---|---|
| 不确定使用哪个引擎 | 从 auto endpoint 开始。它会选择正确路径并记住成功的配置。 |
| 内容为空 | 将 single endpoint 切换为 browser endpoint:页面可能需要 JS 渲染 |
| response 中出现 CAPTCHA | 切换至 proxy endpoint 以使用自动 IP 轮换 |
| 超时 | 增加 timeout_ms 或检查 URL 是否正确 |
| 丢失 key | 在 API Keys 中点击 key 所在行的眼睛图标查看,若是旧版 key 则重新生成 |
后续步骤
- Dashboard Overview:Dashboard 完整演示
- Playground:在编写代码前于 Dashboard 中测试 request
- Smart Fetch (Auto):深入了解 auto endpoint
- Choosing the Right Endpoint:详细对比
- Common Issues:快速解决问题