POST https://api.serphubapi.com/v1/fetch
传入一个 URL,返回去掉导航、广告和模板内容后的网页正文,可直接放进 agent 的上下文。每页 3 积分,失败不计费。
| 参数 | 类型 | 默认值 | 说明 |
|---|
url | string | — | 必填。 网页 URL(http 或 https,须可公开访问)。 |
format | string | markdown | markdown 或 text(去除 Markdown 语法的纯文本)。 |
mode | string | live | live 实时抓取。cache_first 允许返回 1 小时内抓取过的副本,命中缓存免费。 |
指向内网、本机或其他非公开地址的 URL 会被拒绝,返回 400 validation_error。
curl -X POST https://api.serphubapi.com/v1/fetch \
-H "X-API-Key: shapi_xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/blog/espresso-guide", "format": "markdown"}'
{
"meta": {
"id": "fet_01J9Z4A2BC",
"status": "success",
"engine": "fetch",
"cached": false,
"credits_charged": 3,
"time_ms": 1240
},
"url": "https://example.com/blog/espresso-guide",
"title": "The Complete Espresso Guide",
"markdown": "# The Complete Espresso Guide\n\nPulling a good shot starts with ..."
}
| 字段 | 类型 | 说明 |
|---|
meta | object | 结构同搜索,engine 恒为 fetch。 |
url | string | 你请求的 URL。 |
title | string | 网页标题(能识别时返回)。 |
markdown | string | 正文内容。format=text 时为纯文本,字段名仍为 markdown。 |
| 情况 | 积分 |
|---|
| 抓取成功 | 3 |
cache_first 命中缓存 | 0 |
| 抓取失败 | 0 |
| HTTP | 错误码 | 场景 |
|---|
| 400 | validation_error | url 缺失或无效,或该 URL 无法公开访问 |
| 401 | invalid_api_key | Key 缺失、无效或已停用 |
| 402 | insufficient_balance | 可用积分不足 3 |
| 429 | rate_limited | 触发限流,或达到 Key 的每日积分上限 |
| 502 | all_upstreams_failed | 网页未能抓取(被拦截、超时、页面过大等),不计费 |
- 想一次拿到搜索结果背后的网页正文,直接在
/v1/search 上使用 include_content 即可,省去一次往返。
- 部分网站会拦截自动化访问或需要登录,这类请求返回
502,不收费。
- 抓取结果不会进入搜索存档;如之后还要用,请自行保存。