> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/cn/proxies/residential-proxies/location-settings/di-li-ha-xi.md).

# 地理哈希

使用地理哈希定位住宅代理。了解如何选择 1 级到 4 级网格单元，并查看大致单元大小。

要从特定的地理哈希网格单元获取代理，请添加 `geohash` 标志到授权字符串中。当前支持的网格单元范围从级别 1（最大）到级别 4（最小），例如 `9`, `c`, `gc`, `u09`, `drq4`.

以下是一些有效的 `geohash` 值：

* `geohash-9` – 美国和墨西哥大部分地区的随机出口节点
* `geohash-c` – 美国北部和加拿大
* `geohash-gc` – 爱尔兰、北爱尔兰、英格兰和苏格兰
* `geohash-u09` – 巴黎
* `geohash-drq4` – 楠塔基特岛的大部分地区

按地理哈希长度计算的近似单元大小如下：

<table><thead><tr><th width="185.1640625">长度</th><th width="304.51171875">近似单元大小</th></tr></thead><tbody><tr><td>1</td><td>≤ 5,000 km × 5,000 km</td></tr><tr><td>2</td><td>≤ 1,250 km × 625 km</td></tr><tr><td>3</td><td>≤ 156 km × 156 km</td></tr><tr><td>4</td><td>≤ 39.1 km × 19.5 km</td></tr></tbody></table>

{% hint style="info" %}
该 `geohash` 参数与其他地理位置参数互斥，例如洲、国家、城市和 ZIP/邮政编码。
{% endhint %}

#### 凭证列表示例

示例表示一个指向不同地理哈希网格单元的凭证列表。

```shellscript
customer-USERNAME-geohash-9:PASSWORD
customer-USERNAME-geohash-gc:PASSWORD
customer-USERNAME-geohash-u09:PASSWORD
customer-USERNAME-geohash-drq4:PASSWORD
```

#### 代码示例

在此示例中，对 `ip.oxylabs.io/location` 的查询是从 `u09` 地理哈希网格单元（巴黎）中的随机 IP 地址发起的：

{% tabs %}
{% tab title="cURL" %}

```shell
curl -x pr.oxylabs.io:7777 -U "customer-USERNAME-geohash-u09:PASSWORD" https://ip.oxylabs.io/location
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$username = 'USERNAME';
$password = 'PASSWORD';
$geohash = 'u09';
$proxy = 'pr.oxylabs.io:7777';
$query = curl_init('https://ip.oxylabs.io/location');
curl_setopt($query, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($query, CURLOPT_PROXY, "http://$proxy");
curl_setopt($query, CURLOPT_PROXYUSERPWD, "customer-$username-geohash-$geohash:$password");
$output = curl_exec($query);
curl_close($query);
if ($output)
    echo $output;
?>
```

{% endtab %}

{% tab title="Python" %}

```python
import urllib.request
import random
username = 'USERNAME'
password = 'PASSWORD'
geohash = 'u09'
entry = ('http://customer-%s-geohash-%s:%s@pr.oxylabs.io:7777' %
    (username, geohash, password))
query = urllib.request.ProxyHandler({
    'http': entry,
    'https': entry,
})
execute = urllib.request.build_opener(query)
print(execute.open('https://ip.oxylabs.io/location').read())
```

{% endtab %}

{% tab title="Java" %}

```java
package example;

import org.apache.http.HttpHost;
import org.apache.http.client.fluent.*;

public class Example {
    public static void main(String[] args) throws Exception {
        HttpHost entry = new HttpHost("pr.oxylabs.io", 7777);
        String query = Executor.newInstance()
            .auth(entry, "customer-USERNAME-geohash-u09", "PASS")
            .execute(Request.Get("http://ip.oxylabs.io/location").viaProxy(entry))
            .returnContent().asString();
        System.out.println(query);
    }
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Net;

class Example
{
    static void Main()
    {
        var client = new WebClient();
        client.Proxy = new WebProxy("pr.oxylabs.io:7777");
        client.Proxy.Credentials = new NetworkCredential("customer-USERNAME-geohash-u09", "PASSWORD");
        Console.WriteLine(client.DownloadString("https://ip.oxylabs.io/location"));
    }
}
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'uri'
require 'net/http'

uri = URI.parse('https://ip.oxylabs.io/location')
proxy = Net::HTTP::Proxy('pr.oxylabs.io', 7777, 'customer-USERNAME-geohash-u09', 'PASSWORD')

req = Net::HTTP::Get.new(uri.path)

result = proxy.start(uri.host,uri.port) do |http|
    http.request(req)
end

puts result.body

```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://developers.oxylabs.io/products/cn/proxies/residential-proxies/location-settings/di-li-ha-xi.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
