# 本地化查询

本文档介绍了如何将本地化参数与 SERP API 结合使用，以根据用户的首选语言和位置定制搜索结果。

### 本地化参数[​](https://serp-api.netnut.io/docs/SERP/API%20Examples/Query%20with%20Localization#parameters-for-localization) <a href="#parameters-for-localization" id="parameters-for-localization"></a>

SERP API 提供了三个用于本地化的可选参数：

googleDomain（可选）：此参数定义要使用的Google 域名。默认设置为 [www.google.com。确保在域名前包含“www”。](http://www.google.com。确保在域名前包含“www”。)<br>

gl（可选）：此参数定义用于 Google 搜索的国家/地区。它应该是两个字母的国家/地区代码（例如，us 代表美国，uk 代表英国，fr 代表法国）。

hl（可选）：此参数用于定义 Google 搜索的语言。它应该是两个字母的语言代码（例如，en 代表英语，es 代表西班牙语，fr 代表法语）。您可以在[Google languages page](https://www.google.com/preferences?hl=en)上找到受支持的 Google 语言的完整列表。

### 使用本地化参数[​](https://serp-api.netnut.io/docs/SERP/API%20Examples/Query%20with%20Localization#using-localization-parameters) <a href="#using-localization-parameters" id="using-localization-parameters"></a>

要自定义 SERP API 本地化请求，请在 GET 请求中包含本地化参数。 这是使用各种编程语言的示例：

* Bash
* Javascript
* Python
* Go

```
curl -L 'https://serp-api.netnut.io/search?device=desktop&q=news&gl=us&hl=en' \
-H 'Accept: application/json' \
-H 'Authorization: Basic base64(username:password)'
```

### API 响应 <a href="#api-response" id="api-response"></a>

当您包含本地化参数时，API 响应将包含根据指定国家/地区和语言首选项定制的搜索结果。

本文档演示了如何使用本地化参数来自定义您的 SERP API 请求。 您可以调整 gl 和 hl 参数，获得与所需位置和语言选项相匹配的搜索结果。

```
{
    "url": "https://www.google.com/search?q=news&hl=en&gl=US",
    "general": {
        "searchEngine": "google",
        "resultsCount": 25270000000,
        "searchTime": 0.61,
        "language": "en",
        "mobile": false,
        "searchType": "text",
        "pageTitle": "news - Google Search",
        "timestamp": "2023-10-01T12:41:07.971Z"
    },
    "input": {
        "originalUrl": "https://www.google.com/search?q=news&hl=en&gl=US",
        "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
        "jobId": "a21a4108-6669-4abf-9afd-2ba7fd95fafc"
    },
    "organic": [
        {
            "title": "Google News",
            "description": "3 hours ago — Comprehensive up-to-date news coverage, aggregated from sources all over the world by Google News.",
            "link": "https://news.google.com/",
            "displayLink": "https://news.google.com",
            "rank": 1,
            "globalRank": 1
        },
        {
            "title": "NBC News - Breaking News & Top Stories - Latest World, US ...",
            "description": "Go to NBCNews.com for breaking news, videos, and the latest top stories in world news, business, politics, health and pop culture.",
            "link": "https://www.nbcnews.com/",
            "displayLink": "https://www.nbcnews.com",
            "rank": 2,
            "globalRank": 2
        },
        {
            "title": "CNN: Breaking News, Latest News and Videos",
            "description": "4 hours ago — View the latest news and breaking news today for U.S., world, weather, entertainment, politics and health at CNN.com.",
            "link": "https://www.cnn.com/",
            "displayLink": "https://www.cnn.com",
            "rank": 3,
            "globalRank": 3
        },
        {
            "title": "Fox News - Breaking News Updates | Latest News Headlines ...",
            "description": "23 hours ago — Breaking News, Latest News and Current News from FOXNews.com. Breaking news and video. Latest Current News: U.S., World, Entertainment, ...",
            "link": "https://www.foxnews.com/",
            "displayLink": "https://www.foxnews.com",
            "rank": 4,
            "globalRank": 4
        },
        {
            "title": "ABC News - Breaking News, Latest News and Videos",
            "description": "4 hours ago — Your trusted source for breaking news, analysis, exclusive interviews, headlines, and videos at ABCNews.com.",
            "link": "https://abcnews.go.com/",
            "displayLink": "https://abcnews.go.com",
            "rank": 5,
            "globalRank": 5
        },
        {
            "title": "CBS News - Breaking news, 24/7 live streaming news & top ...",
            "description": "2 hours ago — Watch CBS News live and get the latest, breaking news headlines of the day for national news and world news today.",
            "link": "https://www.cbsnews.com/",
            "displayLink": "https://www.cbsnews.com",
            "rank": 6,
            "globalRank": 6
        },
        {
            "title": "U.S. News & World Report: News, Rankings and Analysis on ...",
            "description": "US News is a recognized leader in college, grad school, hospital, mutual fund, and car rankings. Track elected officials, research health conditions, ...",
            "link": "https://www.usnews.com/",
            "displayLink": "https://www.usnews.com",
            "rank": 7,
            "globalRank": 7
        },
        {
            "title": "Associated Press News: Breaking News, Latest Headlines ...",
            "description": "6 hours ago — Read the latest headlines, breaking news, and videos at APNews.com, the definitive source for independent journalism from every corner of the globe.",
            "link": "https://apnews.com/",
            "displayLink": "https://apnews.com",
            "rank": 8,
            "globalRank": 8
        }
    ],
    "pagination": {
        "currentPage": 1,
        "nextPage": 2,
        "nextPageLink": "https://www.google.com/search?q=news&sca_esv=569845833&hl=en&gl=US&ei=4mgZZdvlI9-awbkPtNSuoAs&start=10&sa=N",
        "nextPageStart": 10
    }
}
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.netnut.io/netnut-documentation/netnut-documentation-chn/netnut-zhua-qu-api/sou-suo-jie-guo-ye-mian-serp-api/api-shi-fan/ben-di-hua-cha-xun.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
