主题
重定向链查询
接口概述
重定向链是指从初始 URL 到最终目标 URL 之间存在至少两次跳转的。 例如:页面 A 重定向到页面 B,页面 B 再重定向到页面 C,这组跳转就构成一条重定向链。
如果中间页面又跳回起始页面,例如页面 B 又重定向回页面 A,则会形成封闭的重定向链,也就是重定向循环。
通过本接口,你可以获取构成重定向链的完整 URL 列表,快速识别多级跳转与循环跳转问题,便于排查抓取效率、页面权重传递和用户访问体验问题。
- 请求方法:
POST - 接口地址:
https://api.seermartech.cn/v3/on_page/redirect_chains
计费说明
调用本接口本身不额外收费。 你可以在任务结果生成后的 30 天获取结果。
扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求说明
所有 POST 数据均需使用 JSON(UTF-8 编码)格式提交。 请求体为 JSON 数组格式:
json
[
{
"id": "07131248-1535-0216-1000-17384017ad04",
"url": "https://example.com/page-a"
}
],id 为通过 /v3/on_page/task_post/ 创建任务后返回的任务 ID。
请求参数
| 字段名 | 类型 | 填 | 说明 |
|---|---|---|---|
id | string | 是 | 任务 ID。可从 /v3/on_page/task_post/ 的响应中获取。示例:07131248-1535-0216-1000-17384017ad04 |
url | string | 否 | 页面绝对 URL。若传该字段,响应返回该 URL 的重定向链 |
limit | integer | 否 | 返回的重定向链最大数量。默认值:100;最大值:1000 |
offset | integer | 否 | 返回结果中的偏移量。默认值:0;最大值:2000000。例如设置为 10 时,将跳过前 10 条重定向链并返回后续数据 |
filters | array | 否 | 结果过滤参数数组。本接口支持一个过滤条件。支持字段:is_redirect_loop;支持操作符:regex、not_regex、=、<> |
tag | string | 否 | 自定义任务标识,最大长度 255。可用于业务侧请求与结果。响应中的 data 对象会返回该值 |
过滤规则
本接口支持按 is_redirect_loop 过滤结果,用于区分普通重定向链与重定向循环。
支持的操作符:
regexnot_regex=<>
示例思路:
- 查看循环跳转:过滤
is_redirect_loop = true - 排除循环跳转:过滤
is_redirect_loop <> true
响应结构
接口返回 JSON 数据,顶层 tasks 数组。
顶层字段
| 字段名 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本 |
status_code | integer | 通用状态码,完整列表见 /v3/appendix/errors |
status_message | string | 通用信息提示,完整列表见 /v3/appendix/errors |
time | string | 执行耗时,单位秒 |
cost | float | 本次请求总成本 |
tasks_count | integer | tasks 数组中的任务数 |
tasks_error | integer | 返回错误的任务数 |
tasks | array | 任务结果列表 |
建议在接时对
status_code和任务级错误建立完整异常处理机制。
tasks 数组字段
| 字段名 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识,UUID 格式 |
status_code | integer | 任务状态码,范围通常为 10000-60000,完整列表见 /v3/appendix/errors |
status_message | string | 任务提示信息 |
time | string | 任务执行耗时,单位秒 |
cost | float | 单个任务成本 |
result_count | integer | result 数组中的数量 |
path | array | URL 路径 |
data | object | 与请求中提交的参数一致 |
result | array | 结果数组 |
result 数组字段
| 字段名 | 类型 | 说明 |
|---|---|---|
crawl_progress | string | 抓取会话状态,可选值:in_progress、finished |
crawl_status | object | 抓取会话 |
total_items_count | integer | 数据库中符合条件的总条目数 |
items_count | integer | 当前结果中的条目数 |
items | array | 重定向链列表 |
crawl_status 字段
| 字段名 | 类型 | 说明 |
|---|---|---|
max_crawl_pages | integer | 抓取页面上限,即创建任务时设置的 max_crawl_pages |
pages_in_queue | integer | 当前仍在抓取队列中的页面数 |
pages_crawled | integer | 已抓取页面数 |
items 数组字段
| 字段名 | 类型 | 说明 |
|---|---|---|
is_redirect_loop | boolean | 是否为重定向循环。若为 true,表示链路最后一个 URL 又跳回原始 URL |
chain | array | 构成重定向链的链接列表 |
chain 数组字段
chain 中每一项表示一次跳转。
| 字段名 | 类型 | 说明 |
|---|---|---|
type | string | 链接类型,固定为 redirect,表示 HTTP 3xx 重定向 |
domain_from | string | 来源域名,即发现该链接的域名 |
domain_to | string | 目标域名,即链接指向的域名 |
page_from | string | 来源页面的相对 URL |
page_to | string | 目标页面的相对 URL |
link_from | string | 来源页面绝对 URL |
link_to | string | 目标页面绝对 URL |
dofollow | boolean | 是否为 dofollow。若为 true,表示该链接不含 rel="nofollow" 属性 |
page_from_scheme | string | 来源页面的 URL scheme |
page_to_scheme | string | 目标页面的 URL scheme |
direction | string | 链接方向,可选值:internal、external |
is_broken | boolean | 是否指向损坏页面或不可用资源 |
is_link_relation_conflict | boolean | 是否存在链接冲突。若为 true,表示至少有一个指向 link_to 的链接带 rel="nofollow",且至少还有一个为 dofollow |
请求示例
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://test_rdr.本平台.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"
}
payload = [
{
"id": "03051327-4536-0216-1000-3b458a2cfcca",
"url": "https://test_rdr.本平台.com/a/"
}
]
response = requests.post(url, json=payload, headers=headers)
print(response.json)TypeScript
typescript
import axios from "axios";
const payload = [
{
id: "03051327-4536-0216-1000-3b458a2cfcca",
url: "https://test_rdr.本平台.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: payload
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error(error);
});响应示例
json
{
"version": "0.1.20210622",
"status_code": 20000,
"status_message": "Ok.",
"time": "2.9408 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"data": {
"api": "on_page",
"function": "redirect_chains",
"url": "https://test_rdr.本平台.com/a/"
},
"result": []
}
]
}使用建议
- 如果你要排查特定页面的跳转问题,可传
url,返回该页面的重定向链 - 若抓取仍在进行中,可通过
crawl_progress判断结果是否完整 - 对大站点建议合
limit与offset分页获取结果 - 若重点排查死循环跳转,可使用
is_redirect_loop作为过滤条件
错误处理
请重点以下两个层级的状态:
- 请求级状态
- 顶层
status_code - 顶层
status_message
- 任务级状态
tasks[].status_codetasks[].status_message
完整错误码与提示信息请参考 /v3/appendix/errors。
实用场景
- 定位多级跳转链:识别页面从旧地址到最终落地页之间的多次 3xx 跳转,减少抓取损耗并提升页面访问速度
- 排查重定向循环:筛出
is_redirect_loop = true的异常链路,搜索引擎和用户陷无限跳转 - 审计站迁移质量:在域名切换、目录改版或 HTTPS 迁移后,检查是否存在不的中间跳转,降低 SEO 权重流失风险
- 验证特定页面跳转路径:结合
url参数查看某个重点页面参与的重定向链,快速确认落地页是否正确 - 发现异常目标资源:通过
is_broken等字段识别跳转后落失效页面或损坏资源的链路,及时修复影响收录和转化的问题