SerpHubAPI

正文抓取

POST /v1/fetch——以 Markdown 或纯文本获取任意公开网页清洗后的正文。

POST https://api.serphubapi.com/v1/fetch

传入一个 URL,返回去掉导航、广告和模板内容后的网页正文,可直接放进 agent 的上下文。每页 3 积分,失败不计费。

请求参数

参数类型默认值说明
urlstring—必填。 网页 URL(http 或 https,须可公开访问)。
formatstringmarkdownmarkdown 或 text(去除 Markdown 语法的纯文本)。
modestringlivelive 实时抓取。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 ..."
}
字段类型说明
metaobject结构同搜索,engine 恒为 fetch。
urlstring你请求的 URL。
titlestring网页标题(能识别时返回)。
markdownstring正文内容。format=text 时为纯文本,字段名仍为 markdown。

计费

情况积分
抓取成功3
cache_first 命中缓存0
抓取失败0

错误

HTTP错误码场景
400validation_errorurl 缺失或无效,或该 URL 无法公开访问
401invalid_api_keyKey 缺失、无效或已停用
402insufficient_balance可用积分不足 3
429rate_limited触发限流,或达到 Key 的每日积分上限
502all_upstreams_failed网页未能抓取(被拦截、超时、页面过大等),不计费

提示

  • 想一次拿到搜索结果背后的网页正文,直接在 /v1/search 上使用 include_content 即可,省去一次往返。
  • 部分网站会拦截自动化访问或需要登录,这类请求返回 502,不收费。
  • 抓取结果不会进入搜索存档;如之后还要用,请自行保存。