发送首次 Request
本指南将引导您创建 API key 并使用 FourA Dashboard 发送您的首次 request。
步骤 1:打开 Dashboard
访问 Dashboard 并登录您的 FourA 账号。
步骤 2:创建 API Key
前往 API Keys 页面并点击 Create Key。
为该 key 命名一个描述性名称(例如 "production-scraper" 或 "dev-testing")。完整的 key 仅显示一次,请立即复制。
您的 key 类似于:pk_live_a1b2c3d4e5f6...
步骤 3:选择 Endpoint
FourA 针对不同场景提供了三个 endpoint:
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。最适合有机器人检测或地理限制内容的网站。
步骤 4:发送您的首次 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"}'
步骤 5:读取 Response
{
"status": 200,
"headers": [["content-type", "text/html"]],
"data": "<html>...</html>",
"total_time": 0.45
}
关键字段:
- status:目标网站的 HTTP 状态码
- data:response body(HTML、JSON 或原始文本)
- total_time:request 耗时(秒)
步骤 6:尝试 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>"
}
常见问题
| 问题 | 解决方案 |
|---|---|
| 内容为空 | 从 single 切换到 browser endpoint:该页面可能需要 JS 渲染 |
| Response 中出现 CAPTCHA | 切换到 proxy endpoint 以进行自动 IP 轮换 |
| 超时 | 增加 timeout_ms 或验证 URL 是否正确 |
后续步骤
- Dashboard Overview:完整的 Dashboard 演示
- Playground:在编写代码前,先在 Dashboard 中测试 request
- Choosing the Right Endpoint:详细对比
- Common Issues:快速解决问题