> ## Documentation Index
> Fetch the complete documentation index at: https://docs.querying.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Google 新闻结果 API

> 获取 Google 新闻标签页针对某个搜索列出的文章，最多 10 页，附带媒体、日期和链接。

`GOOGLE_NEWS` 返回 Google 搜索的“新闻”标签页针对某个查询列出的文章。它每页读取约 10 篇文章，最多读取 10 页，并跨页保持 Google 的排序，因此你能追踪 Google 针对某个话题、品牌或竞争对手展示哪些媒体，以及这些媒体随时间的变化。

| | |
| - | - |
| `taskType` | `GOOGLE_NEWS` |
| 输入 | `query`（必填）；`pages`、`country`、`device`、`hl` |
| 积分 | 每读取一个新闻页 1 积分。每页约有 10 篇文章。 |
| 国家 | 默认 `US`。可使用任意 ISO 3166-1 alpha-2 代码。 |

## 请求

下面的请求获取在美国搜索电动汽车关税时新闻标签页的前两页：

```bash theme={"theme":"css-variables"}
curl -X POST https://api.querying.ai/v1/async/task \
  -H "Authorization: Bearer $QUERYING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "taskType": "GOOGLE_NEWS", "payload": { "query": "electric vehicle tariffs", "country": "US", "pages": 2 } }'
```

任务异步执行。按[异步任务](https://docs.querying.ai/zh/concepts/async-tasks.md)中的说明读取结果。

## 参数

| 字段 | 必填 | 说明 |
| - | - | - |
| `query` | 是 | 搜索查询，1-100,000 个字符。缺少 `query` 时接受 `prompt`。 |
| `pages` | 否 | 要读取的新闻页数，1 到 10 的整数，默认 `1`。 |
| `country` | 否 | 要搜索的 Google 市场，默认 `US`。页面语言默认随国家而定，可以用 `hl` 覆盖。 |
| `device` | 否 | 默认 `desktop`。`mobile` 或 `android` 读取 Android 手机 Chrome 渲染的页面。`ios` 返回 `422`。 |
| `hl` | 否 | Google 的 `hl`，新闻页面的界面语言。默认跟随 `country` 的语言。文章日期和界面文字使用该语言。`pt-br` 按 `pt-BR` 读取。 |

## 响应

例如上面请求的结果：

```json theme={"theme":"css-variables"}
{
  "newsResults": [
    {
      "position": 1,
      "title": "...",
      "link": "https://...",
      "snippet": "...",
      "source": "...",
      "date": "3 hours ago",
      "page": 1,
      "thumbnail": "..."
    },
    { "position": 11, "page": 2, "...": "..." }
  ],
  "pages": 2
}
```

| 字段 | 说明 |
| - | - |
| `newsResults` | 始终存在，按 Google 的顺序排列。每篇文章带有 `position`、`title`、`link`、`page`，Google 展示时还带有 `snippet`、`source`、`date` 和 `thumbnail`。 |
| `newsResults[].position` | 文章在整个列表中的排名，从 1 开始，跨页累计。 |
| `newsResults[].page` | 文章所在的新闻页，1 到 10。 |
| `newsResults[].link` | 文章的地址。未能及时读取 Google 的重定向时为空，此时重定向在 `redirectLink` 中。 |
| `newsResults[].redirectLink` | Google 以重定向形式给出链接时的该重定向。空的 `link` 请用 [`POST /v1/google/goto`](https://docs.querying.ai/zh/api-reference/google-goto) 解析。 |
| `newsResults[].date` | Google 显示的发布时长或日期，使用页面语言。 |
| `pages` | 读取的新闻页数。任务按此计费。 |

如果 Google 的列表在达到 `pages` 之前结束，`newsResults` 会包含 Google 列出的全部文章，`pages` 计入实际读取的页数。除 `position`、`title`、`link` 和 `page` 外，请把每个字段都当作可选字段。

## 积分

每读取一个新闻页扣 1 积分。任务开始时，按你请求的页数冻结积分：默认为 1，`pages: 10` 为 10。完成时按实际读取的页数扣费，因此 Google 的列表在第 3 页结束时扣 3 积分。失败的任务扣 0。见[积分与限制](https://docs.querying.ai/zh/concepts/credits-and-limits.md)。

## 限制与错误

* 已完成任务中的 `newsResults` 为空，表示 Google 没有为该查询列出任何文章。返回前会在第二个浏览器上确认，并扣 1 积分。
* 不是 `en`、`de`、`pt-BR` 这类语言代码的 `hl` 返回 `422 VALIDATION_ERROR`。
* 超出 1-10 的 `pages` 或不是 `desktop`、`mobile`、`android` 的 `device` 返回 `422 VALIDATION_ERROR`。
* `state` 和 `uule` 返回 `422 LOCATION_UNSUPPORTED`。请用 `country` 指定市场。
* `include.rawResponse` 不起作用，`include.html` 和 `include.analysis` 返回 `422`。见[Markdown 与原始响应](https://docs.querying.ai/zh/engines/response-options.md)。
* 其他请求错误见[错误](https://docs.querying.ai/zh/concepts/errors.md)。

## 相关内容

* [Google 搜索](https://docs.querying.ai/zh/engines/google-serp.md)：带自然结果的单个结果页
* [解析 Google 重定向](https://docs.querying.ai/zh/api-reference/google-goto.md)
* [积分与限制](https://docs.querying.ai/zh/concepts/credits-and-limits.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.