Skip to content

按资源查询页面

POST /v3/on_page/pages_by_resource

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

POST https://api.seermartech.cn/v3/on_page/pages_by_resource

本接口用于查询指定资源所在的页面列表,并返回这些页面的抓取状态、页面 SEO 数据、指标、资源错误及性能指标等信息。资源 URL 可通过 /v3/on_page/resources/ 获取。

计费说明

本接口不收取额外费用。任务结果可在提交后的 30 天获取,响应中的 cost 通常为 0

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

请求说明

所有 POST 数据均须使用 UTF-8 编码的 JSON 格式。请求体是 JSON 数组,每个数组代表一个任务。

请求参数

参数类型说明
idstring任务 ID。可从 /v3/on_page/task_post/ 的响应中获取。示例:07131248-1535-0216-1000-17384017ad04
urlstring资源 URL。可从 /v3/on_page/resources/ 的响应中获取。例如:https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js
limitinteger最多返回的页面数量。默认值为 100,最大值为 1000
offsetinteger结果偏移量。默认值为 0,最大值为 2000000。例如设置为 10,则跳过结果数组中的前 10 条记录。
filtersarray结果过滤条件。最多支持 8 个过滤条件,可使用 andor 连接。
order_byarray结果排序规则。最多支持 3 条排序规则,排序值可使用 ascdesc
tagstring用户自定义任务标识,最长 255 个字符。该值会原样返回在响应任务的 data 对象中。

filters 过滤器

支持以下运算符:

regexnot_regex<<=>>==<>innot_inlikenot_like

likenot_like 支持使用 % 匹零个或多个字符。

示例:

json
[
  ["status_code", "=", 200],
  "and",
  ["checks.is_https", "=", true]
]

更多过滤字段和阈值请参考 /v3/on_page/filters_and_thresholds/

order_by 排序

排序规则格式为:

json
[
  "onpage_score,desc",
  "click_depth,asc"
]

多个排序规则使用逗号分隔,单个请求最多设置 3 条规则。

请求示例

curl

bash
curl --location --request POST \
  "https://api.seermartech.cn/v3/on_page/pages_by_resource" \
  --header "Authorization: Bearer smt_live_YOUR_KEY" \
  --header "Content-Type: application/json" \
  --data-raw '[
    {
      "id": "02241700-1535-0216-0000-034137259bc1",
      "url": "https://www.etsy.com/about/jobs.workco2018.js?",
      "limit": 3
    }
  ]'

Python

python
import requests

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

payload = [
    {
        "id": "02241700-1535-0216-0000-034137259bc1",
        "url": "https://www.etsy.com/about/jobs.workco2018.js?",
        "limit": 3
    }
]

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

response = requests.post(url, headers=headers, json=payload)
result = response.json()

if result.get("status_code") == 20000:
    print(result)
else:
    print(
        "请求失败,状态码:{},信息:{}".format(
            result.get("status_code"),
            result.get("status_message")
        )
    )

TypeScript

typescript
import axios from "axios";

const response = await axios.post(
  "https://api.seermartech.cn/v3/on_page/pages_by_resource",
  [
    {
      id: "02241700-1535-0216-0000-034137259bc1",
      url: "https://www.etsy.com/about/jobs.workco2018.js?",
      limit: 3
    }
  ],
  {
    headers: {
      Authorization: "Bearer smt_live_YOUR_KEY",
      "Content-Type": "application/json"
    }
  }
);

if (response.data.status_code === 20000) {
  console.log(response.data);
} else {
  console.error(
    `请求失败,状态码:${response.data.status_code},信息:${response.data.status_message}`
  );
}

响应结构

响应为 JSON 对象,顶层 tasks 数组。

顶层字段

字段类型说明
versionstring当前 API 版本。
status_codeinteger通用响应状态码。20000 表示成功。完整错误码请参考 /v3/appendix/errors
status_messagestring通用状态信息。
timestring请求执行耗时,单位为秒。
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
tasks_countintegertasks 数组中的任务总数。
tasks_errorintegertasks 数组中执行失败的任务数。
tasksarray任务结果数组。

任务字段

字段类型说明
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抓取会话。
items_countinteger当前结果中的项目数。
itemsarray页面项目数组。

crawl_status

字段类型说明
max_crawl_pagesinteger创建任务时指定的最大抓取页面数。
pages_in_queueinteger当前抓取队列中的页面数。
pages_crawledinteger已抓取页面数。
total_items_countinteger数据库中符合条件的结果总数。

页面结果字段

每个 items素通常 html_pagecontentspellresource_errorspage_timingcache_controlchecks 等对象。

html_page 页面基本信息

字段类型说明
resource_typestring资源类型。本接口返回页面资源时为 html
status_codeinteger页面 HTTP 状态码。
locationstringLocation 响应头中的重定向地址。
urlstring页面 URL。
metaobject页面信息。
titlestring页面标题。
charsetinteger页面编码代码,例如 65001
followbooleanmeta robots 是否跟踪页面链接。若为 false,通常表示页面 nofollow 指令。
generatorstringgenerator标签。
htagsobjectHTML 标题标签信息 h1h2h3h4 等。
descriptionstringdescription标签。
faviconstring页面 favicon 地址。
meta_keywordsstringkeywords标签。
canonicalstring规范 URL。
internal_links_countinteger页面链接数量。
external_links_countinteger页面外部链接数量。
images_countinteger图片数量。
images_sizeinteger图片总大小,单位为字节。
scripts_countintegerJavaScript 脚本数量。
scripts_sizeintegerJavaScript 总大小,单位为字节。
stylesheets_countinteger样式表数量。
stylesheets_sizeinteger样式表总大小,单位为字节。
title_lengthintegertitle 标签字符数。
description_lengthintegerdescription 标签字符数。
render_blocking_scripts_countinteger阻塞页面渲染的脚本数量。
render_blocking_stylesheets_countinteger阻塞页面渲染的样式表数量。
cumulative_layout_shiftfloatCLS(累计布局偏移)指标,用于衡量页面布局稳定性。
total_dom_sizeinteger页面 DOM 总大小。

content指标

字段类型说明
plain_text_sizeinteger页面纯文本总大小,单位为字节。
plain_text_ratefloat纯文本占页面大小的比例,即 plain_text_size / size
plain_text_word_countfloat页面单词数量。
automated_readability_indexfloat自动可读性指数。
coleman_liau_readability_indexfloatColeman–Liau 可读性指数。
dale_chall_readability_indexfloatDale–Chall 可读性指数。
flesch_kincaid_readability_indexfloatFlesch–Kincaid 可读性指数。
smog_readability_indexfloatSMOG 可读性指数。
description_to_content_consistencyfloatdescription 与页面正文的一致性,范围为 01
title_to_content_consistencyfloattitle 与页面正文的一致性,范围为 01
meta_keywords_to_content_consistencyfloatkeywords 与页面正文的一致性,范围为 01
deprecated_tagsarray页面中的废弃 HTML 标签。
duplicate_meta_tagsarray重复的标签。

spell 拼写检查

字段类型说明
hunspell_language_codestring拼写检查使用的语言代码。
misspelledarray拼写错误单词数组。
misspelled[].wordstring拼写错误的单词。

resource_errors 资源错误

字段类型说明
errorsarray资源错误列表。
errors[].lineinteger错误所在的 HTML 行号。
errors[].messagestring错误信息。
warningsarray资源警告列表。
warnings[].lineinteger警告的 HTML 行号。为 0 时表示警告适用于整个页面。
warnings[].messagestring警告信息。

常见警告:

  • Has node with more than 60 childs.:HTML 页面存在同一层级嵌套 60 个子节点的标签。
  • Has more that 1500 nodes.:DOM 树 1,500 个。
  • HTML depth more than 32 tags.:HTML DOM 深度 32 层。

social_media_tags 社交媒体标签

对象中页面检测到的社交媒体标签及,支持但不限于 Open Graph 和 Twitter Card 标签,例如:

  • og:title
  • og:description
  • og:site_name
  • og:locale
  • fb:app_id

page_timing 页面性能指标

字段类型说明
time_to_interactiveintegerTTI,可交互时间,单位为毫秒。
dom_completeinteger页面及子资源下载完成所需时间,单位为毫秒。
largest_contentful_paintfloatLCP,最大绘制时间,单位为毫秒。
first_input_delayfloatFID,首次延迟,单位为毫秒。
connection_timeinteger建立服务器连接所需时间,单位为毫秒。
time_to_secure_connectioninteger建立连接所需时间,单位为毫秒。
request_sent_timeinteger请求发送完成时间,单位为毫秒。
waiting_timeintegerTTFB,首字节时间,单位为毫秒。
download_timeinteger浏览器接收响应所需时间,单位为毫秒。
duration_timeinteger接收完整响应所需的总时间,单位为毫秒。
fetch_startinteger开始下载 HTML 资源的时间。
fetch_endinteger完成下载 HTML 资源的时间。

页面 SEO 与资源字段

字段类型说明
onpage_scorefloat页面 SEO 优化评分,满分为 100
custom_js_responsestring/object/integer执行自定义 JavaScript 后的结果。字段类型取决于脚本返回值。需在创建任务时 custom_js
custom_js_client_exceptionstring执行自定义 JavaScript 时发生的错误信息。
broken_resourcesboolean页面是否失效资源。
broken_linksboolean页面是否失效链接。
duplicate_titleboolean页面是否存在重复标题。
duplicate_descriptionboolean页面是否存在重复描述。
duplicate_contentboolean页面是否存在重复。
click_depthinteger从首页到达该页面所需的点击层级。
sizeinteger页面资源大小,单位为字节。
encoded_sizeinteger页面编码后的大小,单位为字节。
total_transfer_sizeinteger压缩后的传输大小,单位为字节。
fetch_timestring资源抓取时间,UTC 格式:yyyy-MM-dd HH:mm:ss +00:00
content_encodingstring编码类型,例如 gzip
media_typestring页面媒体类型,例如 text/html
serverstring服务器版本信息。
is_resourceboolean当前页面是否为单独资源。

cache_control 缓存信息

字段类型说明
cachableboolean页面是否可缓存。
ttlinteger缓存有效期,单位取决于平台返回值。

checks 页面检查结果

字段类型说明
no_content_encodingboolean页面是否未使用压缩。
high_loading_timeboolean页面加载时间是否 3 秒。
is_redirectboolean页面是否发生 3XX 重定向。
is_4xx_codeboolean页面是否返回 4xx 状态码。
is_5xx_codeboolean页面是否返回 5xx 状态码。
is_brokenboolean页面是否损坏,即响应码小于 200 或大于 400
is_wwwboolean页面是否位于 www 子域名。
is_httpsboolean页面是否使用 HTTPS。
is_httpboolean页面是否使用 HTTP。
high_waiting_timebooleanTTFB 是否 1.5 秒。
no_doctypeboolean页面是否缺少 DOCTYPE 声明。
canonicalboolean页面是否设置了规范 URL。
no_encoding_meta_tagboolean页面是否缺少字符编码标签。
no_h1_tagboolean页面是否缺少或为空的 H1 标签。
https_to_http_linksbooleanHTTPS 页面是否链接到 HTTP 页面。
has_html_doctypeboolean页面是否 HTML DOCTYPE 声明。
size_greater_than_3mbboolean页面大小是否 3 MB。
meta_charset_consistencyboolean页面声明的字符集是否与字符集不一致。
has_meta_refresh_redirectboolean页面是否使用 meta refresh 重定向。
has_render_blocking_resourcesboolean页面是否阻塞渲染的资源。
redirect_chainboolean页面是否经过至少两次重定向。
low_content_rateboolean纯文本与页面大小的比例是否低于 0.1
high_content_rateboolean纯文本与页面大小的比例是否高于 0.9
low_character_countboolean页面字符数是否少于 1024
high_character_countboolean页面字符数是否 256000
small_page_sizeboolean页面大小是否小于 1024 字节。
large_page_sizeboolean页面大小是否 1 MB。
low_readability_ratebooleanFlesch–Kincaid 可读性评分是否低于 15。
irrelevant_descriptionbooleandescription 是否与页面不,性阈值为 0.2
irrelevant_titlebooleantitle 是否与页面不,性阈值为 0.3
irrelevant_meta_keywordsbooleankeywords 是否与页面不,性阈值为 0.6
title_too_longbooleantitle 是否 65 个字符。
title_too_shortbooleantitle 是否少于 30 个字符。
deprecated_html_tagsboolean页面是否废弃 HTML 标签。
duplicate_meta_tagsboolean页面是否存在同类型重复标签。
duplicate_title_tagboolean页面是否多个 title 标签。
no_image_altboolean图片是否缺少 alt 属性。
no_image_titleboolean图片是否缺少 title 属性。
no_descriptionboolean页面是否缺少或为空的 description 标签。
no_titleboolean页面是否缺少或为空的 title 标签。
no_faviconboolean页面是否缺少 favicon。
seo_friendly_urlbooleanURL 是否符合 SEO 友好标准。
flashboolean页面是否 Flash素。
frameboolean页面是否 frameiframeframeset 标签。
lorem_ipsumboolean页面是否 Lorem Ipsum 占位文本。
has_misspellingboolean页面是否拼写错误。
seo_friendly_url_characters_checkbooleanURL 是否大小写拉丁字母、数字和连字符。
seo_friendly_url_dynamic_checkbooleanURL 是否不动态参数。
seo_friendly_url_keywords_checkbooleanURL 是否与页面标题。
seo_friendly_url_relative_length_checkbooleanURL 相对路径是否不 120 个字符。
is_orphan_pageboolean页面是否为孤立页面,即没有站页面链接指向该页面。
is_link_relation_conflictboolean指向该页面的站链接中是否同时存在 dofollow 和 nofollow。
has_links_to_redirectsboolean页面是否链接到会发生 3XX 重定向的页面。
canonical_chainbooleancanonical 是否形成链式指向。
canonical_to_redirectbooleancanonical 是否指向会发生重定向的页面。
canonical_to_brokenbooleancanonical 是否指向返回 4xx5xx 的页面。
recursive_canonicalbooleancanonical 是否形成循环指向。
from_sitemapboolean页面是否来自站点地图。

flashframe、部分 URL 检查及链接检查外,部分检查项在 canonical 检查结果为 true 时提供。

seo_friendly_url 通常综合以下条件判断:

  • 相对路径长度少于 120 个字符;
  • 不特殊字符;
  • 不动态参数;
  • URL 与页面。

last_modified 最后修改时间

字段类型说明
headerstring/nullHTTP Header 中记录的最后修改时间,UTC 格式。
sitemapstring/null站点地图中记录的最后修改时间,UTC 格式。
meta_tagstring/null页面标签中记录的最后修改时间,UTC 格式。

如果没有对应数据,字段值为 null

响应示例

json
{
  "version": "0.1.20210129",
  "status_code": 20000,
  "status_message": "Ok.",
  "time": "3.3012 sec.",
  "cost": 0,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "02241700-1535-0216-0000-034137259bc1",
      "status_code": 20000,
      "status_message": "Ok.",
      "time": "3.3012 sec.",
      "cost": 0,
      "result_count": 1,
      "data": {
        "api": "on_page",
        "function": "pages_by_resource",
        "url": "https://www.etsy.com/about/jobs.workco2018.js?",
        "limit": 3
      },
      "result": [
        {
          "crawl_progress": "finished",
          "crawl_status": {
            "max_crawl_pages": 3,
            "pages_in_queue": 0,
            "pages_crawled": 3,
            "total_items_count": 1,
            "items_count": 1
          },
          "items": [
            {
              "html_page": {
                "resource_type": "html",
                "status_code": 200,
                "location": null,
                "url": "https://www.etsy.com/about/",
                "meta": {
                  "title": "About Etsy",
                  "charset": 65001,
                  "follow": true,
                  "generator": null,
                  "htags": {
                    "h1": ["About Etsy"],
                    "h2": [],
                    "h4": []
                  },
                  "description": "Etsy is the first e-commerce company to be carbon neutral.",
                  "favicon": "https://www.etsy.com/images/favicon.ico",
                  "meta_keywords": null,
                  "canonical": null,
                  "internal_links_count": 44,
                  "external_links_count": 9,
                  "images_count": 2,
                  "images_size": 0,
                  "scripts_count": 10,
                  "scripts_size": 405515,
                  "stylesheets_count": 4,
                  "stylesheets_size": 130964,
                  "title_length": 55,
                  "description_length": 205,
                  "render_blocking_scripts_count": 4,
                  "render_blocking_stylesheets_count": 10,
                  "cumulative_layout_shift": 0.101563
                },
                "content": {
                  "plain_text_size": 10755,
                  "plain_text_rate": 0.083324,
                  "plain_text_word_count": 1413,
                  "automated_readability_index": 19.595897,
                  "coleman_liau_readability_index": 9.494734,
                  "dale_chall_readability_index": 11.023805,
                  "flesch_kincaid_readability_index": 2.203208,
                  "smog_readability_index": 24.268042,
                  "description_to_content_consistency": 0.214286,
                  "title_to_content_consistency": 0.333333,
                  "meta_keywords_to_content_consistency": null,
                  "deprecated_tags": null,
                  "duplicate_meta_tags": []
                },
                "spell": null,
                "resource_errors": {
                  "errors": [],
                  "warnings": []
                },
                "social_media_tags": {
                  "og:site_name": "Etsy",
                  "og:locale": "de_DE",
                  "og:title": "About Etsy",
                  "og:description": "Etsy is the first e-commerce company to be carbon neutral."
                }
              },
              "page_timing": {
                "time_to_interactive": 835,
                "dom_complete": 1073,
                "largest_contentful_paint": 1648.475,
                "first_input_delay": 0.055,
                "connection_time": 9,
                "time_to_secure_connection": 10,
                "request_sent_time": 0,
                "waiting_time": 452,
                "download_time": 6,
                "duration_time": 477,
                "fetch_start": 0,
                "fetch_end": 477
              },
              "onpage_score": 88.36,
              "total_dom_size": 3627018,
              "custom_js_response": null,
              "custom_js_client_exception": null,
              "broken_resources": false,
              "broken_links": false,
              "duplicate_title": false,
              "duplicate_description": false,
              "duplicate_content": false,
              "click_depth": 1,
              "size": 129259,
              "encoded_size": 33427,
              "total_transfer_size": 34948,
              "fetch_time": "2021-02-24 17:04:54 +00:00",
              "cache_control": {
                "cachable": false,
                "ttl": 0
              },
              "checks": {
                "no_content_encoding": false,
                "high_loading_time": false,
                "is_redirect": false,
                "is_4xx_code": false,
                "is_5xx_code": false,
                "is_broken": false,
                "is_www": true,
                "is_https": true,
                "is_http": false,
                "high_waiting_time": false,
                "no_doctype": false,
                "canonical": true,
                "no_encoding_meta_tag": true,
                "no_h1_tag": false,
                "https_to_http_links": true,
                "has_html_doctype": true,
                "size_greater_than_3mb": false,
                "meta_charset_consistency": true,
                "has_meta_refresh_redirect": false,
                "has_render_blocking_resources": true,
                "redirect_chain": false,
                "low_content_rate": true,
                "low_readability_rate": true,
                "duplicate_meta_tags": true,
                "no_image_alt": true,
                "no_image_title": true,
                "seo_friendly_url": false,
                "is_orphan_page": false,
                "canonical_chain": false,
                "canonical_to_redirect": false,
                "canonical_to_broken": false,
                "recursive_canonical": false,
                "from_sitemap": false
              },
              "content_encoding": "gzip",
              "media_type": "text/html",
              "server": "Apache",
              "is_resource": false,
              "last_modified": {
                "header": "2021-10-21 14:11:10 +00:00",
                "sitemap": null,
                "meta_tag": "2021-03-15 00:00:00 +00:00"
              }
            }
          ]
        }
      ]
    }
  ]
}

状态码与异常处理

建议客户端同时检查:

  • HTTP 状态码;
  • 顶层 status_code
  • 任务级 tasks[].status_code
  • tasks_error 是否大于 0
  • status_message 中的错误信息。

完整状态码和错误说明请参考 /v3/appendix/errors

实用场景

  • 定位引用指定 JavaScript、CSS 或图片资源的页面,评估资源变更或失效对站点 SEO 和用户体验的影响。
  • 筛查引用失效资源的页面,结合 broken_resources、HTTP 状态码和 resource_errors 快速安排修复。
  • 分析资源影响范围,根据页面 URL、点击深度、链接数量和页面评分确定优优化页面。
  • 评估引用资源页面的性能表现,使用 LCP、TTI、TTFB、加载时间和阻塞资源指标定位性能瓶颈。
  • 批量检查页面 SEO 质量,利用标题、描述、规范 URL、重复、图片替代文本及 URL 友好度等字段制定修复单。

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