AP News Search
AP News Search 用于按关键词获取 AP News 搜索结果数据。
- 按关键词抓取 AP News 新闻搜索结果
- 支持按地区发起请求
- 支持从指定页开始连续抓取多页结果
- 返回结果列表、分页信息和文章元数据
使用 XCrawl 获取 AP News 搜索结果
使用方式
curl -s -X POST 'https://run.xcrawl.com/v1/data' \
-H 'Authorization: Bearer $XCRAWL_API_KEY'\
-H 'Content-Type: application/json' \
-d '{
"engine": "apnews_search",
"keyword": "coffee",
"location": "US",
"start_page": 1,
"pages": 1
}'请求参数说明:
engine固定为apnews_searchkeyword用于指定搜索关键词location用于指定请求地区start_page和pages用于控制抓取页码范围
响应示例
{
"result": [
{
"content": {
"query": "coffee",
"base_url": "https://apnews.com",
"current_page": 1,
"total_pages": 20,
"page_size": 30,
"result_count": 30,
"total_results": 9517,
"next_page_url": "https://apnews.com/search?q=coffee&p=2",
"source_url": "https://apnews.com/search?q=coffee&p=1",
"result": [
{
"position": 1,
"title": "Soaring coffee prices rewrite some Americans' daily routines",
"summary": "Rising coffee prices are changing how some Americans get their caffeine.",
"url": "https://apnews.com/article/coffee-inflation-prices-starbucks-1a809b2d3e650d5e92e2c0f5a5f4f85b",
"article_id": "coffee-inflation-prices-starbucks-1a809b2d3e650d5e92e2c0f5a5f4f85b",
"published_at": "2026-02-14T14:00:07+00:00",
"updated_at": "2026-02-14T16:58:45+00:00",
"image_url": "https://dims.apnews.com/...",
"source": "AP News",
"content_type": "article"
}
]
}
}
]
}参数说明
必填参数
| 参数 | 类型 | 说明 |
|---|---|---|
location | string | 指定请求地区。 |
keyword | string | 指定搜索关键词。 |
start_page | number | 指定从第几页开始抓取。 |
pages | number | 指定连续抓取的页数。 |
参数补充说明
location默认值为USlocation支持多个地区值,例如US、HK、CA、GB、JPkeyword默认值为coffeestart_page默认值为1pages默认值为1
响应字段
响应数据位于 result[].content。
| 字段 | 类型 | 说明 |
|---|---|---|
query | string | 最终生效的搜索关键词。 |
base_url | string | 用于补全相对链接的站点基础地址。 |
current_page | number | 当前结果页码。 |
total_pages | number | 搜索结果总页数。 |
page_size | number | 当前页包含的结果数量。 |
result_count | number | 当前响应实际返回的结果数量。 |
total_results | number | 搜索结果总条数。 |
next_page_url | string | 下一页结果链接。 |
source_url | string | 本次抓取的原始搜索页链接。 |
result | array | 搜索结果列表。 |
结果项字段
result[] 中每一项通常包含以下字段:
| 字段 | 类型 | 说明 |
|---|---|---|
position | number | 当前页内的结果位置,从 1 开始。 |
title | string | 新闻标题。 |
summary | string | 结果摘要。 |
content | string | 内容摘要字段,通常与摘要文本一致。 |
url | string | 文章详情链接。 |
path | string | 文章链接的路径部分。 |
article_id | string | 从文章链接中解析出的文章标识。 |
domain | string | 结果对应的域名。 |
display_date | string | 页面展示的日期文本。 |
timestamp_ms | string | 页面主时间戳,单位为毫秒。 |
published_timestamp_ms | string | 发布时间戳,单位为毫秒。 |
updated_timestamp_ms | string | 更新时间戳,单位为毫秒。 |
published_at | string | ISO 8601 格式的发布时间。 |
updated_at | string | ISO 8601 格式的更新时间。 |
image_url | string | 主图链接。 |
image_srcset | string | 响应式图片 srcset 信息。 |
image_alt | string | 图片替代文本。 |
image_width | number | 图片宽度。 |
image_height | number | 图片高度。 |
image_aspect_ratio | number | 图片宽高比。 |
has_image | boolean | 是否包含图片。 |
has_media | boolean | 是否包含媒体内容。 |
gtm_region | string | 结果卡片中的 GTM 区域标识。 |
gtm_topic | string | 结果卡片中的 GTM 主题标识。 |
origin_template | string | 结果卡片声明的模板名称。 |
mobile_alt_layout | boolean | 是否启用了移动端替代布局。 |
source | string | 来源名称。 |
content_type | string | 根据结果链接归一化后的内容类型。 |
