主题
重定向链查询
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 数组,数组中的每个对象代表一个任务。
请求参数
| 字段 | 类型 | 填 | 说明 |
|---|---|---|---|
id | string | 是 | 任务 ID。该 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 对象中。 |
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 数组。每个任务对应一个提交时的请求对象。
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 请求级状态码。 |
status_message | string | 请求级状态说明。 |
time | string | 接口执行耗时,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
tasks_count | integer | tasks 数组中的任务总数。 |
tasks_error | integer | tasks 数组中返回错误的任务数量。 |
tasks | array | 任务结果数组。 |
tasks 数组中的字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识,采用 UUID 格式。 |
status_code | integer | 任务状态码,范围为 10000–60000。 |
status_message | string | 任务状态说明。 |
time | string | 任务执行耗时,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
result_count | integer | result 数组中的结果数量。 |
path | array | URL 路径信息。 |
data | object | 与提交任务时相同的请求参数。 |
result | array | 任务结果数组。 |
result 字段
| 字段 | 类型 | 说明 |
|---|---|---|
crawl_progress | string | 爬取会话状态。可选值:in_progress、finished。 |
crawl_status | object | 爬取会话。 |
items | array | 重定向链项目数组。 |
crawl_status 字段
| 字段 | 类型 | 说明 |
|---|---|---|
max_crawl_pages | integer | 最大爬取页面数,即创建任务时设置的 max_crawl_pages。 |
pages_in_queue | integer | 当前仍在爬取队列中的页面数量。 |
pages_crawled | integer | 已爬取页面数量。 |
total_items_count | integer | 数据库中符合条件的项目总数。 |
items_count | integer | 当前结果数组中的项目数量。 |
items 字段
| 字段 | 类型 | 说明 |
|---|---|---|
is_redirect_loop | boolean | 表示重定向链的起点和终点是否为同一 URL。为 true 时,链中的最后一个 URL 会重定向回原始 URL。 |
chain | array | 构成重定向链的链接数组。 |
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,例如 http 或 https。 |
page_to_scheme | string | 目标页面的 URL Scheme。 |
direction | string | 链接方向。可选值:internal、external。 |
is_broken | boolean | 链接是否失效,表示链接是否指向失效页面或资源。 |
is_link_relation_conflict | boolean | 链接是否存在冲突。为 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_code 和 status_message 判断请求及任务是否成功。建议客户端针对网络异常、无效任务 ID、参数校验失败、任务处理失败等实现重试、告警和错误记录机制。
实用场景
- 定位多跳重定向:识别经过两次或更多次跳转的 URL,减少页面加载延迟并改善抓取效率。
- 检测重定向循环:筛选
is_redirect_loop=true的结果,及时修复页面无法正常访问的问题。 - 核查网站迁移链路:检查旧 URL 到新 URL 的跳转路径,验证域名迁移或 URL 结构调整是否存在异常。
- 发现失效跳转目标:结合
is_broken字段定位指向错误页面或失效资源的重定向,降低用户访问损失。 - 审计与外部跳转:利用
direction、domain_from和domain_to区分站外重定向,评估 SEO 权重传递和第三方跳转风险。