Skip to content

重定向链查询

POST /v3/on_page/redirect_chains

本接口使用 POST 方法,路径为:

/v3/on_page/redirect_chains

重定向链是指初始 URL 与目标 URL 之间至少存在两次重定向。例如,页面 A 重定向到页面 B,页面 B 又重定向到页面 C,这一系列跳转即构成重定向链。如果页面 B 进一步重定向回页面 A,则该链路会闭合,并被识别为重定向循环。

本接口返回构成重定向链的完整 URL 列表,可用于快速定位和追踪多次重定向、重定向循环及链接问题。

计费说明

本接口当前不收取费用。任务结果可在提交后的 30 天获取。

扣费以响应头 X-SeerMarTech-Charge-CNY 为准。

请求说明

  • 请求方法:POST
  • 请求地址:https://api.seermartech.cn/v3/on_page/redirect_chains
  • 请求格式:application/json
  • 字符编码:UTF-8
  • 请求体是 JSON 数组,数组中的每个对象代表一个任务。

请求参数

字段类型说明
idstring任务 ID。该 ID 来自 /v3/on_page/task_post 接口的任务提交响应。示例:07131248-1535-0216-1000-17384017ad04
urlstring页面绝对 URL。指定后返回该 URL 的重定向链。
limitinteger返回的最大重定向链数量。默认值:100;最大值:1000
offsetinteger结果数组的偏移量。默认值:0;最大值:2000000。例如设置为 10 时,将跳过前 10 条结果。
filtersarray结果过滤条件。本接口最多只能使用一个过滤条件。支持字段:is_redirect_loop;支持运算符:regexnot_regex=<>
tagstring用户自定义任务标识,最多 255 个字符。可用于任务与结果。提交的值会出现在响应的 data 对象中。

filters 示例

json
[
  {
    "id": "07131248-1535-0216-1000-17384017ad04",
    "filters": [
      ["is_redirect_loop", "=", true]
    ]
  }
]

请求示例

cURL

bash
curl --location --request POST \
  "https://api.seermartech.cn/v3/on_page/redirect_chains" \
  --header "Authorization: Bearer smt_live_YOUR_KEY" \
  --header "Content-Type: application/json" \
  --data-raw '[
    {
      "id": "03051327-4536-0216-1000-3b458a2cfcca",
      "url": "https://example.com/a/"
    }
  ]'

Python

python
import requests

url = "https://api.seermartech.cn/v3/on_page/redirect_chains"

headers = {
    "Authorization": "Bearer smt_live_YOUR_KEY",
    "Content-Type": "application/json"
}

post_data = [
    {
        "id": "03051327-4536-0216-1000-3b458a2cfcca",
        "url": "https://example.com/a/"
    }
]

response = requests.post(url, headers=headers, json=post_data)

if response.status_code == 200:
    result = response.json()
    print(result)
else:
    print(f"请求失败:HTTP {response.status_code}{response.text}")

TypeScript

typescript
import axios from "axios";

const postData = [
  {
    id: "03051327-4536-0216-1000-3b458a2cfcca",
    url: "https://example.com/a/"
  }
];

axios({
  method: "post",
  url: "https://api.seermartech.cn/v3/on_page/redirect_chains",
  headers: {
    Authorization: "Bearer smt_live_YOUR_KEY",
    "Content-Type": "application/json"
  },
  data: postData
})
  .then((response) => {
    // 处理响应数据
    console.log(response.data);
  })
  .catch((error) => {
    console.error("请求失败:", error.response?.data || error.message);
  });

响应结构

接口返回 JSON 数据 tasks 数组。每个任务对应一个提交时的请求对象。

顶层字段

字段类型说明
versionstring当前 API 版本。
status_codeinteger请求级状态码。
status_messagestring请求级状态说明。
timestring接口执行耗时,单位为秒。
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
tasks_countintegertasks 数组中的任务总数。
tasks_errorintegertasks 数组中返回错误的任务数量。
tasksarray任务结果数组。

tasks 数组中的字段

字段类型说明
idstring任务唯一标识,采用 UUID 格式。
status_codeinteger任务状态码,范围为 1000060000
status_messagestring任务状态说明。
timestring任务执行耗时,单位为秒。
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
result_countintegerresult 数组中的结果数量。
patharrayURL 路径信息。
dataobject与提交任务时相同的请求参数。
resultarray任务结果数组。

result 字段

字段类型说明
crawl_progressstring爬取会话状态。可选值:in_progressfinished
crawl_statusobject爬取会话。
itemsarray重定向链项目数组。

crawl_status 字段

字段类型说明
max_crawl_pagesinteger最大爬取页面数,即创建任务时设置的 max_crawl_pages
pages_in_queueinteger当前仍在爬取队列中的页面数量。
pages_crawledinteger已爬取页面数量。
total_items_countinteger数据库中符合条件的项目总数。
items_countinteger当前结果数组中的项目数量。

items 字段

字段类型说明
is_redirect_loopboolean表示重定向链的起点和终点是否为同一 URL。为 true 时,链中的最后一个 URL 会重定向回原始 URL。
chainarray构成重定向链的链接数组。

chain 字段

字段类型说明
typestring链接类型,固定为 redirect,表示 HTTP 3xx 重定向。
domain_fromstring来源域名,发现该链接的域名。
domain_tostring目标域名,链接指向的域名。
page_fromstring来源页面的相对 URL。
page_tostring目标页面的相对 URL。
link_fromstring来源页面的绝对 URL。
link_tostring目标页面的绝对 URL。
dofollowboolean是否为 dofollow 链接。为 true 表示该链接不 rel="nofollow" 属性。
page_from_schemestring来源页面的 URL Scheme,例如 httphttps
page_to_schemestring目标页面的 URL Scheme。
directionstring链接方向。可选值:internalexternal
is_brokenboolean链接是否失效,表示链接是否指向失效页面或资源。
is_link_relation_conflictboolean链接是否存在冲突。为 true 时,至少有一个指向 link_to 的链接带有 rel="nofollow",同时至少有一个链接为 dofollow。

响应示例

json
{
  "version": "0.1.20210622",
  "status_code": 20000,
  "status_message": "Ok.",
  "time": "2.9408 sec.",
  "cost": 0,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "03051327-4536-0216-1000-3b458a2cfcca",
      "status_code": 20000,
      "status_message": "Ok.",
      "time": "2.9100 sec.",
      "cost": 0,
      "result_count": 1,
      "path": [
        "v3",
        "on_page",
        "redirect_chains"
      ],
      "data": {
        "api": "on_page",
        "function": "redirect_chains",
        "id": "03051327-4536-0216-1000-3b458a2cfcca",
        "url": "https://example.com/a/"
      },
      "result": [
        {
          "crawl_progress": "finished",
          "crawl_status": {
            "max_crawl_pages": 100,
            "pages_in_queue": 0,
            "pages_crawled": 12,
            "total_items_count": 1,
            "items_count": 1
          },
          "items": [
            {
              "is_redirect_loop": false,
              "chain": [
                {
                  "type": "redirect",
                  "domain_from": "example.com",
                  "domain_to": "example.com",
                  "page_from": "/a/",
                  "page_to": "/b/",
                  "link_from": "https://example.com/a/",
                  "link_to": "https://example.com/b/",
                  "dofollow": true,
                  "page_from_scheme": "https",
                  "page_to_scheme": "https",
                  "direction": "internal",
                  "is_broken": false,
                  "is_link_relation_conflict": false
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

状态码与异常处理

请根据响应中的 status_codestatus_message 判断请求及任务是否成功。建议客户端针对网络异常、无效任务 ID、参数校验失败、任务处理失败等实现重试、告警和错误记录机制。

实用场景

  • 定位多跳重定向:识别经过两次或更多次跳转的 URL,减少页面加载延迟并改善抓取效率。
  • 检测重定向循环:筛选 is_redirect_loop=true 的结果,及时修复页面无法正常访问的问题。
  • 核查网站迁移链路:检查旧 URL 到新 URL 的跳转路径,验证域名迁移或 URL 结构调整是否存在异常。
  • 发现失效跳转目标:结合 is_broken 字段定位指向错误页面或失效资源的重定向,降低用户访问损失。
  • 审计与外部跳转:利用 directiondomain_fromdomain_to 区分站外重定向,评估 SEO 权重传递和第三方跳转风险。

统一入口:官网 · LLM API · 控制台