资源分析
POST
/v3/on_page/resources获取已爬取页面加载的资源清单(JS、CSS、图片、字体等),用于性能优化与资源体积审计。
参考价:约 ¥0.0040 / 次(实际以请求返回为准)
请求体
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | string | 是 | task_post 返回的任务 ID |
| limit | integer | 否 | 返回资源数 |
| filters | array | 否 | 按资源类型过滤 |
请求示例
curl
curl -X POST "https://api.seermartech.cn/v3/on_page/resources" \
-H "Authorization: Bearer smt_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '[{"id": "YOUR_TASK_ID", "limit": 100}]'Python
import requests
resp = requests.post(
"https://api.seermartech.cn/v3/on_page/resources",
headers={"Authorization": "Bearer smt_live_YOUR_KEY"},
json=[{"id": "YOUR_TASK_ID", "limit": 100}],
timeout=120,
)
for r in resp.json()["tasks"][0]["result"][0]["items"][:10]:
print(r.get("resource_type"), r.get("url"), r.get("size"))TypeScript
const resp = await fetch("https://api.seermartech.cn/v3/on_page/resources", {
method: "POST",
headers: { Authorization: "Bearer smt_live_YOUR_KEY", "Content-Type": "application/json" },
body: JSON.stringify([{ id: "YOUR_TASK_ID", limit: 100 }]),
});
console.log((await resp.json()).tasks[0].result[0].items.slice(0, 10));业务场景
- 找出体积过大的 JS/CSS 文件
- 检测第三方脚本加载情况