使用场景
获取页面内容
从任意网页抓取 HTML 内容,用于后续处理或分析
获取 API 数据
向 REST API 发起 GET 请求并获取 JSON 响应
健康检查
监控网站可用性和响应时间
简单下载
下载静态资源、文档或页面内容
Endpoint
POST
/api/v1/tools/fetch_urlAuth Required
Free 计划 2 req/s
1 credit
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | Required | - | 要抓取的 URL(必须包含协议:http:// 或 https://) Example: https://example.com |
headers | object | Optional | - | 请求中要包含的自定义 HTTP 请求头 Example: {"Accept": "text/html", "User-Agent": "MyBot/1.0"} |
timeout | number | Optional | 10000 | 请求超时时间,单位毫秒(1000-30000) Example: 15000 |
follow_redirects | boolean | Optional | true | 是否自动跟随 HTTP 重定向 Example: true |
user_agent | string | Optional | - | 自定义 User-Agent 请求头(覆盖默认值) Example: Mozilla/5.0 (compatible; CrawlBot/1.0) |
请求示例
cURL
terminalBash
TypeScript
fetchUrl.tsTypescript
Python
fetch_url.pyPython
响应示例
200 OK245ms
{ "success": true, "data": { "url": "https://example.com", "status": 200, "status_text": "OK", "headers": { "content-type": "text/html; charset=UTF-8", "content-length": "1256", "server": "nginx" }, "content": "Example Domain ......", "content_length": 1256, "content_type": "text/html; charset=UTF-8", "redirected": false, "final_url": "https://example.com" }, "credits_used": 1, "credits_remaining": 999, "processing_time": 245}Field Descriptions
data.url请求的原始 URLdata.status响应的 HTTP 状态码data.content页面的完整 HTML 内容data.content_length内容大小,单位字节data.final_url跟随重定向后的最终 URLcredits_used本次请求扣除的 credits(每次抓取 1 个)credits_remaining你剩余的 credit 余额错误处理
无效 URL(400 Bad Request)
URL 格式无效。请确保它包含协议(http:// 或 https://)
超时错误(500 Internal Server Error)
请求耗时超过了指定的超时时间。请尝试增大 timeout 参数。
credits 不足(402 Payment Required)
你的账户 credits 不足。购买更多 credits 或 升级你的计划。
超出速率限制(429 Too Many Requests)
你已超出计划的速率限制。请稍候片刻,或 升级你的计划 以获得更高的限额。
专业提示: 生产环境应用应始终实现带指数退避的重试逻辑。最佳实践请参阅我们的 错误处理指南。
credit 费用
1 credit
每次请求 1 credit
每次成功的 fetch_url 请求花费 1 credit,与页面大小或响应时间无关。
Free 计划: 1,000 个一次性试用 credits = 1,000 次请求
Hobby 计划: 每月 5,000 credits = 5,000 次请求($19/mo)
Professional 计划: 每月 50,000 credits = 50,000 次请求($99/mo)
Business 计划: 每月 250,000 credits = 250,000 次请求($399/mo)
相关工具
准备好试用 fetch_url 了吗?免费注册,获取 1,000 credits 开始构建。