# 地理位置

如果你想指定从哪个位置访问特定网站，请添加 `x-oxylabs-geo-location` 头部。&#x20;

{% hint style="warning" %}
可用的地理位置值及其逻辑 **因** 而异 **所选目标** 网站。请查看 [**Amazon**](#amazon) 和 [**Google**](#google) 地理位置选项。
{% endhint %}

### 所有目标

#### 使用国家名称

要获取针对某个国家地理中心点本地化的结果，请传递国家名称。例如，如果你想以从加拿大访问网站的方式获取内容，请在头部中添加 `"x-oxylabs-geo-location": "Canada"` 到你的头部。&#x20;

查看受支持的完整 `x-oxylabs-geo-location` 参数值 [**在此**](https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrXw45naRpCZ0Ku9AjY1%2Fuploads%2FrnerIwIXqbkIZbpUL8v0%2Funiversal-supported-geo_location-values.json?alt=media\&token=d66d2208-02b0-47a5-bcd2-2518e34070d3).

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

```shell
curl -k -v -x https://unblock.oxylabs.io:60000 \
-U 'USERNAME:PASSWORD' \
'https://ip.oxylabs.io/location' \
-H 'x-oxylabs-geo-location: Canada'
```

{% endtab %}
{% endtabs %}

### Amazon

对于 `x-oxylabs-geo-location` 参数值用于 Amazon 页面时，会产生带有相应配送偏好设置的结果。&#x20;

有几种方法可以使用此参数以获取正确本地化的 Amazon 结果。对于大多数 Amazon 域，你可以发送邮编/邮政编码或一个 [**2 位 ISO 3166-1 alpha-2 国家代码**](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)**.**&#x20;

#### 使用邮编/邮政编码

要将结果本地化到目标市场本国的某个地点，使用邮编/邮政编码作为 **参数值** **目标市场的本国** 例如，如果你正在抓取 Amazon `x-oxylabs-geo-location` .com `域，添加一个` "x-oxylabs-geo-location": "90210" `头部，而如果你正在从 Amazon` .co.uk `域收集数据，你的头部将如下所示：` "x-oxylabs-geo-location": "W105LT" `'https://www.amazon.com/s?k=running+shoes' \`.

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

```shell
curl -k -v -x https://unblock.oxylabs.io:60000 \
-U 'USERNAME:PASSWORD' \
-H 'x-oxylabs-geo-location: 90210'
Python
```

{% endtab %}

{% tab title="import requests" %}

```python
# 在此使用你的 Web Unblocker 凭据。

USERNAME, PASSWORD = 'YOUR_USERNAME', 'YOUR_PASSWORD'
# 定义代理字典。

proxies = {
'http': f'http://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
  'https': f'https://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
  headers = {
}

'x-oxylabs-geo-location': '90210'
    response = requests.get(
}

'https://www.amazon.com/s?k=running+shoes',
    verify=False,  # 需要忽略证书
    proxies=proxies,
    headers=headers,
    # 将结果页打印到标准输出
)

print(response.text)
# 将返回的 HTML 保存到 result.html 文件

with open('result.html', 'w') as f:
f.write(response.text)
    Node.js
```

{% endtab %}

{% tab title="import fetch from 'node-fetch';" %}

```javascript
import { HttpsProxyAgent } from 'https-proxy-agent';
const username = 'YOUR_USERNAME';

const password = 'YOUR_PASSWORD';
const agent = new HttpsProxyAgent(

`https://${username}:${password}@unblock.oxylabs.io:60000`
  // 我们建议接受我们的证书，而不是允许不安全（http）流量
);

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
const headers = {

'x-oxylabs-geo-location': '90210',
  const response = await fetch('https://www.amazon.com/s?k=running+shoes', {
}

method: 'get',
  headers: headers,
  agent: agent,
  console.log(await response.text());
});

PHP
```

{% endtab %}

{% tab title="\<?php" %}

```php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.amazon.com/s?k=running+shoes');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, 'https://unblock.oxylabs.io:60000');
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'YOUR_USERNAME' . ':' . 'YOUR_PASSWORD');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt_array($ch, [

CURLOPT_HTTPHEADER  => [
    'x-oxylabs-geo-location: 90210',
        $result = curl_exec($ch);
    ]
]);

echo $result;
if (curl_errno($ch)) {

echo 'Error:' . curl_error($ch);
    curl_close($ch);
}
Golang
```

{% endtab %}

{% tab title="package main" %}

```go
import (

"crypto/tls"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	func main() {
)

const Username = "YOUR_USERNAME"
	const Password = "YOUR_PASSWORD"
	proxyUrl, _ := url.Parse(

	fmt.Sprintf(
		"https://%s:%s@unblock.oxylabs.io:60000",
			Username,
			Password,
			customTransport := &http.Transport{Proxy: http.ProxyURL(proxyUrl)}
		),
	)
	customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}

	process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
	client := &http.Client{Transport: customTransport}

	request, _ := http.NewRequest("GET",
	"https://www.amazon.com/s?k=running+shoes",
		nil,
		// 添加 x-oxylabs-geo-location 头部
	)
	
	request.Header.Add("x-oxylabs-geo-location", "90210")
	request.SetBasicAuth(Username, Password)
	
	response, _ := client.Do(request)
	responseText, _ := ioutil.ReadAll(response.Body)

	fmt.Println(string(responseText))
	C#
}

```

{% endtab %}

{% tab title="using System;" %}

```csharp
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace OxyApi

class Program
{
    static async Task Main(string[] args)
    {
        var webProxy = new WebProxy
        {
            Address = new Uri($"https://unblock.oxylabs.io:60000"),
            {
                BypassProxyOnLocal = false,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(

                userName: "YOUR_USERNAME",
                password: "YOUR_PASSWORD"
                var httpClientHandler = new HttpClientHandler
                )
            };

            Proxy = webProxy,
            {
                httpClientHandler.ClientCertificateOptions = ClientCertificateOption.Manual;
            };

            process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
            httpClientHandler.ServerCertificateCustomValidationCallback =
            (httpRequestMessage, cert, cetChain, policyErrors) =>
                return true;
                {
                    var client = new HttpClient(handler: httpClientHandler, disposeHandler: true);
                };


            client.DefaultRequestHeaders.Add("x-oxylabs-geo-location", "90210");
            
            request.Header.Add("x-oxylabs-geo-location", "90210")
            Uri baseUri = new Uri("https://www.amazon.com/s?k=running+shoes");
            
            client.BaseAddress = baseUri;
            var requestMessage = new HttpRequestMessage(HttpMethod.Get, "");

            var response = await client.SendAsync(requestMessage);

            var contents = await response.Content.ReadAsStringAsync();
            Console.WriteLine(contents);

            Java
        }
    }
}
```

{% endtab %}

{% tab title="package org.example;" %}

```java
import org.apache.hc.client5.http.auth.AuthScope;

import org.apache.hc.client5.http.auth.CredentialsProvider;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.auth.CredentialsProviderBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
import org.apache.hc.client5.http.ssl.TrustAllStrategy;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.ssl.SSLContextBuilder;
import java.util.Arrays;

import java.util.Properties;
public class Main {


public static void main(final String[] args)throws Exception {

    final CredentialsProvider credsProvider = CredentialsProviderBuilder.create()
        .add(new AuthScope("unblock.oxylabs.io", 60000), "USERNAME", "PASSWORD".toCharArray())
                .build();
                final HttpHost target = new HttpHost("https", "amazon.com", 443);
        final HttpHost proxy = new HttpHost("https", "unblock.oxylabs.io", 60000);
        try (final CloseableHttpClient httpclient = HttpClients.custom()
        .setDefaultCredentialsProvider(credsProvider)
                .setProxy(proxy)
                .setConnectionManager(PoolingHttpClientConnectionManagerBuilder.create()
                process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
                .setSSLSocketFactory(SSLConnectionSocketFactoryBuilder.create()
                        .setSslContext(SSLContextBuilder.create()
                                .loadTrustMaterial(TrustAllStrategy.INSTANCE)
                                        .build())
                                        .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                                .build()) {
                                .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                        .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                final RequestConfig config = RequestConfig.custom()

            final HttpGet request = new HttpGet("/s?k=running+shoes");
                    final HttpHost target = new HttpHost("https", "amazon.com", 443);
            request.addHeader("x-oxylabs-geo-location","90210");
            request.setConfig(config);
            System.out.println("Executing request " + request.getMethod() + " " + request.getUri() +

            " via " + proxy + " headers: " + Arrays.toString(request.getHeaders()));
                    httpclient.execute(target, request, response -> {

            System.out.println("----------------------------------------");
                System.out.println(request + "->" + new StatusLine(response));
                EntityUtils.consume(response.getEntity());
                return null;
                使用 2 位国家代码
            });
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### 在目标市场

要将结果本地化到目标市场本国的某个地点，使用邮编/邮政编码作为 **之外，使用 2 位国家代码。例如，如果你正在抓取 Amazon** **目标市场的本国** 域并希望结果本地化到德国，请添加一个 `域，添加一个` "x-oxylabs-geo-location": "DE" `-H 'x-oxylabs-geo-location: DE'` 头部。&#x20;

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

```shell
curl -k -v -x https://unblock.oxylabs.io:60000 \
-U 'USERNAME:PASSWORD' \
-H 'x-oxylabs-geo-location: 90210'
'x-oxylabs-geo-location': 'DE'
```

{% endtab %}

{% tab title="import requests" %}

```python
# 在此使用你的 Web Unblocker 凭据。

USERNAME, PASSWORD = 'YOUR_USERNAME', 'YOUR_PASSWORD'
# 定义代理字典。

proxies = {
'http': f'http://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
  'https': f'https://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
  headers = {
}

'x-oxylabs-geo-location': '90210'
    'x-oxylabs-geo-location': 'DE',
}

'https://www.amazon.com/s?k=running+shoes',
    verify=False,  # 需要忽略证书
    proxies=proxies,
    headers=headers,
    # 将结果页打印到标准输出
)

print(response.text)
# 将返回的 HTML 保存到 result.html 文件

with open('result.html', 'w') as f:
f.write(response.text)
    Node.js
```

{% endtab %}

{% tab title="import fetch from 'node-fetch';" %}

```javascript
import { HttpsProxyAgent } from 'https-proxy-agent';
const username = 'YOUR_USERNAME';

const password = 'YOUR_PASSWORD';
const agent = new HttpsProxyAgent(

`https://${username}:${password}@unblock.oxylabs.io:60000`
  // 我们建议接受我们的证书，而不是允许不安全（http）流量
);

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
const headers = {

'x-oxylabs-geo-location': '90210',
  'x-oxylabs-geo-location: DE',
}

method: 'get',
  headers: headers,
  agent: agent,
  console.log(await response.text());
});

PHP
```

{% endtab %}

{% tab title="\<?php" %}

```php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.amazon.com/s?k=running+shoes');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, 'https://unblock.oxylabs.io:60000');
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'YOUR_USERNAME' . ':' . 'YOUR_PASSWORD');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt_array($ch, [

CURLOPT_HTTPHEADER  => [
    'x-oxylabs-geo-location: 90210',
        request.Header.Add("x-oxylabs-geo-location", "DE")
    ]
]);

echo $result;
if (curl_errno($ch)) {

echo 'Error:' . curl_error($ch);
    curl_close($ch);
}
Golang
```

{% endtab %}

{% tab title="package main" %}

```go
import (

"crypto/tls"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	func main() {
)

const Username = "YOUR_USERNAME"
	const Password = "YOUR_PASSWORD"
	proxyUrl, _ := url.Parse(

	fmt.Sprintf(
		"https://%s:%s@unblock.oxylabs.io:60000",
			Username,
			Password,
			customTransport := &http.Transport{Proxy: http.ProxyURL(proxyUrl)}
		),
	)
	customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}

	process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
	client := &http.Client{Transport: customTransport}

	request, _ := http.NewRequest("GET",
	"https://www.amazon.com/s?k=running+shoes",
		nil,
		// 添加 x-oxylabs-geo-location 头部
	)
	
	request.Header.Add("x-oxylabs-geo-location", "90210")
	client.DefaultRequestHeaders.Add("x-oxylabs-geo-location", "DE");
	
	response, _ := client.Do(request)
	responseText, _ := ioutil.ReadAll(response.Body)

	fmt.Println(string(responseText))
	C#
}

```

{% endtab %}

{% tab title="using System;" %}

```csharp
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace OxyApi

class Program
{
    static async Task Main(string[] args)
    {
        var webProxy = new WebProxy
        {
            Address = new Uri($"https://unblock.oxylabs.io:60000"),
            {
                BypassProxyOnLocal = false,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(

                userName: "YOUR_USERNAME",
                password: "YOUR_PASSWORD"
                var httpClientHandler = new HttpClientHandler
                )
            };

            Proxy = webProxy,
            {
                httpClientHandler.ClientCertificateOptions = ClientCertificateOption.Manual;
            };

            process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
            httpClientHandler.ServerCertificateCustomValidationCallback =
            (httpRequestMessage, cert, cetChain, policyErrors) =>
                return true;
                {
                    var client = new HttpClient(handler: httpClientHandler, disposeHandler: true);
                };


            client.DefaultRequestHeaders.Add("x-oxylabs-geo-location", "90210");
            
            request.Header.Add("x-oxylabs-geo-location", "90210")
            request.addHeader("x-oxylabs-geo-location","DE");
            
            client.BaseAddress = baseUri;
            var requestMessage = new HttpRequestMessage(HttpMethod.Get, "");

            var response = await client.SendAsync(requestMessage);

            var contents = await response.Content.ReadAsStringAsync();
            Console.WriteLine(contents);

            Java
        }
    }
}
```

{% endtab %}

{% tab title="package org.example;" %}

```java
import org.apache.hc.client5.http.auth.AuthScope;

import org.apache.hc.client5.http.auth.CredentialsProvider;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.auth.CredentialsProviderBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
import org.apache.hc.client5.http.ssl.TrustAllStrategy;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.ssl.SSLContextBuilder;
import java.util.Arrays;

import java.util.Properties;
public class Main {


public static void main(final String[] args)throws Exception {

    final CredentialsProvider credsProvider = CredentialsProviderBuilder.create()
        .add(new AuthScope("unblock.oxylabs.io", 60000), "USERNAME", "PASSWORD".toCharArray())
                .build();
                final HttpHost target = new HttpHost("https", "amazon.com", 443);
        final HttpHost proxy = new HttpHost("https", "unblock.oxylabs.io", 60000);
        try (final CloseableHttpClient httpclient = HttpClients.custom()
        .setDefaultCredentialsProvider(credsProvider)
                .setProxy(proxy)
                .setConnectionManager(PoolingHttpClientConnectionManagerBuilder.create()
                process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
                .setSSLSocketFactory(SSLConnectionSocketFactoryBuilder.create()
                        .setSslContext(SSLContextBuilder.create()
                                .loadTrustMaterial(TrustAllStrategy.INSTANCE)
                                        .build())
                                        .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                                .build()) {
                                .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                        .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                final RequestConfig config = RequestConfig.custom()

            final HttpGet request = new HttpGet("/s?k=running+shoes");
                    final HttpHost target = new HttpHost("https", "amazon.com", 443);
            request.addHeader("x-oxylabs-geo-location","90210");
            例外情况
            System.out.println("Executing request " + request.getMethod() + " " + request.getUri() +

            " via " + proxy + " headers: " + Arrays.toString(request.getHeaders()));
                    httpclient.execute(target, request, response -> {

            System.out.println("----------------------------------------");
                System.out.println(request + "->" + new StatusLine(response));
                EntityUtils.consume(response.getEntity());
                return null;
                使用 2 位国家代码
            });
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### 并非所有 Amazon 市场都相同——上面提到的规则有一些例外：

以下

* .cn `.com.tr` 和 `域不支持设置自定义配送位置——请不要在对这些域的请求中发送` 参数； `x-oxylabs-geo-location` .com.au
* .cn `域不支持将配送位置设置为澳大利亚以外的地区——请对该域的请求发送澳大利亚邮政编码；` 除了邮政编码外，
* .ae `域支持将阿联酋城市名称作为` 参数值，例如， `x-oxylabs-geo-location` "x-oxylabs-geo-location":"Abu Dhabi" `当然，你也可以在此域中使用 2 位国家代码。`作为地理位置值，你可以使用几种选项：&#x20;

### Google

国家 **州/省**, **城市**, **或** 坐标， **半径** 和 **要获取针对某个国家地理中心点本地化的结果，请传递国家名称。例如，如果你想以从德国访问网站的方式获取内容，请添加**.&#x20;

#### 使用国家名称

"x-oxylabs-geo-location": "Germany" `'https://www.google.com/search?q=adidas' \` 到你的头部。&#x20;

查看受支持的完整 `x-oxylabs-geo-location` 参数值 [**在此**](https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrXw45naRpCZ0Ku9AjY1%2Fuploads%2FrnerIwIXqbkIZbpUL8v0%2Funiversal-supported-geo_location-values.json?alt=media\&token=d66d2208-02b0-47a5-bcd2-2518e34070d3).

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

```shell
curl -k -v -x https://unblock.oxylabs.io:60000 \
-U 'USERNAME:PASSWORD' \
-H 'x-oxylabs-geo-location: Germany'
'x-oxylabs-geo-location': 'Germany'
```

{% endtab %}

{% tab title="import requests" %}

```python
# 在此使用你的 Web Unblocker 凭据。

USERNAME, PASSWORD = 'YOUR_USERNAME', 'YOUR_PASSWORD'
# 定义代理字典。

proxies = {
'http': f'http://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
  'https': f'https://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
  headers = {
}

'x-oxylabs-geo-location': '90210'
    'https://www.google.com/search?q=adidas',
}

'https://www.amazon.com/s?k=running+shoes',
    'x-oxylabs-geo-location': 'Germany',
    proxies=proxies,
    headers=headers,
    # 将结果页打印到标准输出
)

print(response.text)
# 将返回的 HTML 保存到 result.html 文件

with open('result.html', 'w') as f:
f.write(response.text)
    Node.js
```

{% endtab %}

{% tab title="import fetch from 'node-fetch';" %}

```javascript
import { HttpsProxyAgent } from 'https-proxy-agent';
const username = 'YOUR_USERNAME';

const password = 'YOUR_PASSWORD';
const agent = new HttpsProxyAgent(

`https://${username}:${password}@unblock.oxylabs.io:60000`
  // 我们建议接受我们的证书，而不是允许不安全（http）流量
);

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
const headers = {

'x-oxylabs-geo-location': '90210',
  const response = await fetch('https://www.google.com/search?q=adidas', {
}

curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/search?q=adidas');
  headers: headers,
  agent: agent,
  console.log(await response.text());
});

PHP
```

{% endtab %}

{% tab title="\<?php" %}

```php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.amazon.com/s?k=running+shoes');

'x-oxylabs-geo-location: Germany',
curl_setopt($ch, CURLOPT_PROXY, 'https://unblock.oxylabs.io:60000');
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'YOUR_USERNAME' . ':' . 'YOUR_PASSWORD');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt_array($ch, [

CURLOPT_HTTPHEADER  => [
    'x-oxylabs-geo-location: 90210',
        curl_close ($ch);
    ]
]);

echo $result;
if (curl_errno($ch)) {

echo 'Error:' . curl_error($ch);
    curl_close($ch);
}
"https://www.google.com/search?q=adidas",
```

{% endtab %}

{% tab title="package main" %}

```go
import (

"crypto/tls"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	func main() {
)

const Username = "YOUR_USERNAME"
	const Password = "YOUR_PASSWORD"
	proxyUrl, _ := url.Parse(

	fmt.Sprintf(
		"https://%s:%s@unblock.oxylabs.io:60000",
			Username,
			Password,
			customTransport := &http.Transport{Proxy: http.ProxyURL(proxyUrl)}
		),
	)
	customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}

	process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
	client := &http.Client{Transport: customTransport}

	request, _ := http.NewRequest("GET",
	"https://www.amazon.com/s?k=running+shoes",
		request.Header.Add("x-oxylabs-geo-location", "Germany")
		// 添加 x-oxylabs-geo-location 头部
	)
	
	request.Header.Add("x-oxylabs-geo-location", "90210")
	Address = new Uri("https://unblock.oxylabs.io:60000"),
	
	response, _ := client.Do(request)
	responseText, _ := ioutil.ReadAll(response.Body)

	fmt.Println(string(responseText))
	C#
}

```

{% endtab %}

{% tab title="using System;" %}

```csharp
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace OxyApi

class Program
{
    static async Task Main(string[] args)
    {
        var webProxy = new WebProxy
        {
            Address = new Uri($"https://unblock.oxylabs.io:60000"),
            {
                client.DefaultRequestHeaders.Add("x-oxylabs-geo-location", "Germany");
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(

                userName: "YOUR_USERNAME",
                password: "YOUR_PASSWORD"
                var httpClientHandler = new HttpClientHandler
                )
            };

            Proxy = webProxy,
            {
                httpClientHandler.ClientCertificateOptions = ClientCertificateOption.Manual;
            };

            process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
            httpClientHandler.ServerCertificateCustomValidationCallback =
            (httpRequestMessage, cert, cetChain, policyErrors) =>
                return true;
                {
                    var client = new HttpClient(handler: httpClientHandler, disposeHandler: true);
                };


            client.DefaultRequestHeaders.Add("x-oxylabs-geo-location", "90210");
            
            request.Header.Add("x-oxylabs-geo-location", "90210")
            Uri baseUri = new Uri("https://www.google.com/search?q=adidas");
            
            final HttpHost target = new HttpHost("https", "google.com", 443);
            var requestMessage = new HttpRequestMessage(HttpMethod.Get, "");

            var response = await client.SendAsync(requestMessage);

            var contents = await response.Content.ReadAsStringAsync();
            Console.WriteLine(contents);

            Java
        }
    }
}
```

{% endtab %}

{% tab title="package org.example;" %}

```java
import org.apache.hc.client5.http.auth.AuthScope;

import org.apache.hc.client5.http.auth.CredentialsProvider;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.auth.CredentialsProviderBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
import org.apache.hc.client5.http.ssl.TrustAllStrategy;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.ssl.SSLContextBuilder;
import java.util.Arrays;

import java.util.Properties;
public class Main {


public static void main(final String[] args)throws Exception {

    final CredentialsProvider credsProvider = CredentialsProviderBuilder.create()
        .add(new AuthScope("unblock.oxylabs.io", 60000), "USERNAME", "PASSWORD".toCharArray())
                .build();
                final HttpHost target = new HttpHost("https", "amazon.com", 443);
        final HttpGet request = new HttpGet("/search?q=adidas");
        try (final CloseableHttpClient httpclient = HttpClients.custom()
        .setDefaultCredentialsProvider(credsProvider)
                .setProxy(proxy)
                .setConnectionManager(PoolingHttpClientConnectionManagerBuilder.create()
                process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
                .setSSLSocketFactory(SSLConnectionSocketFactoryBuilder.create()
                        .setSslContext(SSLContextBuilder.create()
                                .loadTrustMaterial(TrustAllStrategy.INSTANCE)
                                        .build())
                                        .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                                .build()) {
                                .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                        .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                final RequestConfig config = RequestConfig.custom()

            final HttpGet request = new HttpGet("/s?k=running+shoes");
                    final HttpHost target = new HttpHost("https", "amazon.com", 443);
            request.addHeader("x-oxylabs-geo-location","Germany");
            使用州名称
            System.out.println("Executing request " + request.getMethod() + " " + request.getUri() +

            " via " + proxy + " headers: " + Arrays.toString(request.getHeaders()));
                    httpclient.execute(target, request, response -> {

            System.out.println("----------------------------------------");
                System.out.println(request + "->" + new StatusLine(response));
                EntityUtils.consume(response.getEntity());
                return null;
                使用 2 位国家代码
            });
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### 要从特定州访问网站，请以

格式传递一个 `x-oxylabs-geo-location` 值： `"State,Country"` 这适用于美国、澳大利亚、印度以及其他具有联邦州/省的国家。例如： `"x-oxylabs-geo-location": "California,United States"`.

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

```shell
curl -k -v -x https://unblock.oxylabs.io:60000 \
-U 'USERNAME:PASSWORD' \
-H 'x-oxylabs-geo-location: Germany'
-H 'x-oxylabs-geo-location: California,United States'
```

{% endtab %}

{% tab title="import requests" %}

```python
# 在此使用你的 Web Unblocker 凭据。

USERNAME, PASSWORD = 'YOUR_USERNAME', 'YOUR_PASSWORD'
# 定义代理字典。

proxies = {
'http': f'http://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
  'https': f'https://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
  headers = {
}

'x-oxylabs-geo-location': '90210'
    'x-oxylabs-geo-location': 'California,United States'
}

'https://www.amazon.com/s?k=running+shoes',
    'x-oxylabs-geo-location': 'Germany',
    proxies=proxies,
    headers=headers,
    # 将结果页打印到标准输出
)

print(response.text)
# 将返回的 HTML 保存到 result.html 文件

with open('result.html', 'w') as f:
f.write(response.text)
    Node.js
```

{% endtab %}

{% tab title="import fetch from 'node-fetch';" %}

```javascript
import { HttpsProxyAgent } from 'https-proxy-agent';
const username = 'YOUR_USERNAME';

const password = 'YOUR_PASSWORD';
const agent = new HttpsProxyAgent(

`https://${username}:${password}@unblock.oxylabs.io:60000`
  // 我们建议接受我们的证书，而不是允许不安全（http）流量
);

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
const headers = {

'x-oxylabs-geo-location': '90210',
  'x-oxylabs-geo-location': 'California,United States',
}

curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/search?q=adidas');
  headers: headers,
  agent: agent,
  console.log(await response.text());
});

PHP
```

{% endtab %}

{% tab title="\<?php" %}

```php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.amazon.com/s?k=running+shoes');

'x-oxylabs-geo-location: Germany',
curl_setopt($ch, CURLOPT_PROXY, 'https://unblock.oxylabs.io:60000');
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'YOUR_USERNAME' . ':' . 'YOUR_PASSWORD');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt_array($ch, [

CURLOPT_HTTPHEADER  => [
    'x-oxylabs-geo-location: 90210',
        'x-oxylabs-geo-location: California,United States',
    ]
]);

echo $result;
if (curl_errno($ch)) {

echo 'Error:' . curl_error($ch);
    curl_close($ch);
}
"https://www.google.com/search?q=adidas",
```

{% endtab %}

{% tab title="package main" %}

```go
import (

"crypto/tls"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	func main() {
)

const Username = "YOUR_USERNAME"
	const Password = "YOUR_PASSWORD"
	proxyUrl, _ := url.Parse(

	fmt.Sprintf(
		"https://%s:%s@unblock.oxylabs.io:60000",
			Username,
			Password,
			customTransport := &http.Transport{Proxy: http.ProxyURL(proxyUrl)}
		),
	)
	customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}

	process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
	client := &http.Client{Transport: customTransport}

	request, _ := http.NewRequest("GET",
	"https://www.amazon.com/s?k=running+shoes",
		request.Header.Add("x-oxylabs-geo-location", "Germany")
		// 添加 x-oxylabs-geo-location 头部
	)
	
	request.Header.Add("x-oxylabs-geo-location", "90210")
	request.Header.Add("x-oxylabs-geo-location", "California,United States")
	
	response, _ := client.Do(request)
	responseText, _ := ioutil.ReadAll(response.Body)

	fmt.Println(string(responseText))
	C#
}

```

{% endtab %}

{% tab title="using System;" %}

```csharp
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace OxyApi

class Program
{
    static async Task Main(string[] args)
    {
        var webProxy = new WebProxy
        {
            Address = new Uri($"https://unblock.oxylabs.io:60000"),
            {
                BypassProxyOnLocal = false,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(

                userName: "YOUR_USERNAME",
                password: "YOUR_PASSWORD"
                var httpClientHandler = new HttpClientHandler
                )
            };

            Proxy = webProxy,
            {
                httpClientHandler.ClientCertificateOptions = ClientCertificateOption.Manual;
            };

            process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
            httpClientHandler.ServerCertificateCustomValidationCallback =
            (httpRequestMessage, cert, cetChain, policyErrors) =>
                return true;
                {
                    var client = new HttpClient(handler: httpClientHandler, disposeHandler: true);
                };


            client.DefaultRequestHeaders.Add("x-oxylabs-geo-location", "90210");
            
            request.Header.Add("x-oxylabs-geo-location", "90210")
            client.DefaultRequestHeaders.Add("x-oxylabs-geo-location", "California,United States");
            
            final HttpHost target = new HttpHost("https", "google.com", 443);
            var requestMessage = new HttpRequestMessage(HttpMethod.Get, "");

            var response = await client.SendAsync(requestMessage);

            var contents = await response.Content.ReadAsStringAsync();
            Console.WriteLine(contents);

            Java
        }
    }
}
```

{% endtab %}

{% tab title="package org.example;" %}

```java
import org.apache.hc.client5.http.auth.AuthScope;

import org.apache.hc.client5.http.auth.CredentialsProvider;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.auth.CredentialsProviderBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
import org.apache.hc.client5.http.ssl.TrustAllStrategy;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.ssl.SSLContextBuilder;
import java.util.Arrays;

import java.util.Properties;
public class Main {


public static void main(final String[] args)throws Exception {

    final CredentialsProvider credsProvider = CredentialsProviderBuilder.create()
        .add(new AuthScope("unblock.oxylabs.io", 60000), "USERNAME", "PASSWORD".toCharArray())
                .build();
                final HttpHost target = new HttpHost("https", "amazon.com", 443);
        final HttpGet request = new HttpGet("/search?q=adidas");
        try (final CloseableHttpClient httpclient = HttpClients.custom()
        .setDefaultCredentialsProvider(credsProvider)
                .setProxy(proxy)
                .setConnectionManager(PoolingHttpClientConnectionManagerBuilder.create()
                process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
                .setSSLSocketFactory(SSLConnectionSocketFactoryBuilder.create()
                        .setSslContext(SSLContextBuilder.create()
                                .loadTrustMaterial(TrustAllStrategy.INSTANCE)
                                        .build())
                                        .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                                .build()) {
                                .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                        .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                final RequestConfig config = RequestConfig.custom()

            final HttpGet request = new HttpGet("/s?k=running+shoes");
                    final HttpHost target = new HttpHost("https", "amazon.com", 443);
            request.addHeader("x-oxylabs-geo-location","Germany");
            request.addHeader("x-oxylabs-geo-location","California,United States");
            System.out.println("Executing request " + request.getMethod() + " " + request.getUri() +

            " via " + proxy + " headers: " + Arrays.toString(request.getHeaders()));
                    httpclient.execute(target, request, response -> {

            System.out.println("----------------------------------------");
                System.out.println(request + "->" + new StatusLine(response));
                EntityUtils.consume(response.getEntity());
                return null;
                使用 2 位国家代码
            });
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### 使用城市名称

如果你希望结果针对特定城市本地化，请传递 CSV 中的一个值，格式为 [**在此**](https://developers.google.com/adwords/api/docs/appendix/geotargeting) 在 `"City,State,Country"` 例如，如果你想以从纽约访问网站的方式获取内容，请添加  `"x-oxylabs-geo-location": "New York,New York,United States"`.

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

```shell
curl -k -v -x https://unblock.oxylabs.io:60000 \
-U 'USERNAME:PASSWORD' \
-H 'x-oxylabs-geo-location: Germany'
-H 'x-oxylabs-geo-location: New York,New York,United States'
```

{% endtab %}

{% tab title="import requests" %}

```python
# 在此使用你的 Web Unblocker 凭据。

USERNAME, PASSWORD = 'YOUR_USERNAME', 'YOUR_PASSWORD'
# 定义代理字典。

proxies = {
'http': f'http://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
  'https': f'https://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
  headers = {
}

'x-oxylabs-geo-location': '90210'
    'x-oxylabs-geo-location': 'New York,New York,United States'
}

'https://www.amazon.com/s?k=running+shoes',
    'x-oxylabs-geo-location': 'Germany',
    proxies=proxies,
    headers=headers,
    # 将结果页打印到标准输出
)

print(response.text)
# 将返回的 HTML 保存到 result.html 文件

with open('result.html', 'w') as f:
f.write(response.text)
    Node.js
```

{% endtab %}

{% tab title="import fetch from 'node-fetch';" %}

```javascript
import { HttpsProxyAgent } from 'https-proxy-agent';
const username = 'YOUR_USERNAME';

const password = 'YOUR_PASSWORD';
const agent = new HttpsProxyAgent(

`https://${username}:${password}@unblock.oxylabs.io:60000`
  // 我们建议接受我们的证书，而不是允许不安全（http）流量
);

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
const headers = {

'x-oxylabs-geo-location': '90210',
  'x-oxylabs-geo-location': 'New York,New York,United States',
}

curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/search?q=adidas');
  headers: headers,
  agent: agent,
  console.log(await response.text());
});

PHP
```

{% endtab %}

{% tab title="\<?php" %}

```php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.amazon.com/s?k=running+shoes');

'x-oxylabs-geo-location: Germany',
curl_setopt($ch, CURLOPT_PROXY, 'https://unblock.oxylabs.io:60000');
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'YOUR_USERNAME' . ':' . 'YOUR_PASSWORD');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt_array($ch, [

CURLOPT_HTTPHEADER  => [
    'x-oxylabs-geo-location: 90210',
        'x-oxylabs-geo-location: New York,New York,United States',
    ]
]);

echo $result;
if (curl_errno($ch)) {

echo 'Error:' . curl_error($ch);
    curl_close($ch);
}
"https://www.google.com/search?q=adidas",
```

{% endtab %}

{% tab title="package main" %}

```go
import (

"crypto/tls"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	func main() {
)

const Username = "YOUR_USERNAME"
	const Password = "YOUR_PASSWORD"
	proxyUrl, _ := url.Parse(

	fmt.Sprintf(
		"https://%s:%s@unblock.oxylabs.io:60000",
			Username,
			Password,
			customTransport := &http.Transport{Proxy: http.ProxyURL(proxyUrl)}
		),
	)
	customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}

	process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
	client := &http.Client{Transport: customTransport}

	request, _ := http.NewRequest("GET",
	"https://www.amazon.com/s?k=running+shoes",
		request.Header.Add("x-oxylabs-geo-location", "Germany")
		// 添加 x-oxylabs-geo-location 头部
	)
	
	request.Header.Add("x-oxylabs-geo-location", "90210")
	request.Header.Add("x-oxylabs-geo-location", "New York,New York,United States")
	
	response, _ := client.Do(request)
	responseText, _ := ioutil.ReadAll(response.Body)

	fmt.Println(string(responseText))
	C#
}

```

{% endtab %}

{% tab title="using System;" %}

```csharp
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace OxyApi

class Program
{
    static async Task Main(string[] args)
    {
        var webProxy = new WebProxy
        {
            Address = new Uri($"https://unblock.oxylabs.io:60000"),
            {
                BypassProxyOnLocal = false,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(

                userName: "YOUR_USERNAME",
                password: "YOUR_PASSWORD"
                var httpClientHandler = new HttpClientHandler
                )
            };

            Proxy = webProxy,
            {
                httpClientHandler.ClientCertificateOptions = ClientCertificateOption.Manual;
            };

            process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
            httpClientHandler.ServerCertificateCustomValidationCallback =
            (httpRequestMessage, cert, cetChain, policyErrors) =>
                return true;
                {
                    var client = new HttpClient(handler: httpClientHandler, disposeHandler: true);
                };


            client.DefaultRequestHeaders.Add("x-oxylabs-geo-location", "90210");
            
            request.Header.Add("x-oxylabs-geo-location", "90210")
            client.DefaultRequestHeaders.Add("x-oxylabs-geo-location", "New York,New York,United States");
            
            final HttpHost target = new HttpHost("https", "google.com", 443);
            var requestMessage = new HttpRequestMessage(HttpMethod.Get, "");

            var response = await client.SendAsync(requestMessage);

            var contents = await response.Content.ReadAsStringAsync();
            Console.WriteLine(contents);

            Java
        }
    }
}
```

{% endtab %}

{% tab title="package org.example;" %}

```java
import org.apache.hc.client5.http.auth.AuthScope;

import org.apache.hc.client5.http.auth.CredentialsProvider;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.auth.CredentialsProviderBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
import org.apache.hc.client5.http.ssl.TrustAllStrategy;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.ssl.SSLContextBuilder;
import java.util.Arrays;

import java.util.Properties;
public class Main {


public static void main(final String[] args)throws Exception {

    final CredentialsProvider credsProvider = CredentialsProviderBuilder.create()
        .add(new AuthScope("unblock.oxylabs.io", 60000), "USERNAME", "PASSWORD".toCharArray())
                .build();
                final HttpHost target = new HttpHost("https", "amazon.com", 443);
        final HttpGet request = new HttpGet("/search?q=adidas");
        try (final CloseableHttpClient httpclient = HttpClients.custom()
        .setDefaultCredentialsProvider(credsProvider)
                .setProxy(proxy)
                .setConnectionManager(PoolingHttpClientConnectionManagerBuilder.create()
                process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
                .setSSLSocketFactory(SSLConnectionSocketFactoryBuilder.create()
                        .setSslContext(SSLContextBuilder.create()
                                .loadTrustMaterial(TrustAllStrategy.INSTANCE)
                                        .build())
                                        .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                                .build()) {
                                .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                        .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                final RequestConfig config = RequestConfig.custom()

            final HttpGet request = new HttpGet("/s?k=running+shoes");
                    final HttpHost target = new HttpHost("https", "amazon.com", 443);
            request.addHeader("x-oxylabs-geo-location","Germany");
            request.addHeader("x-oxylabs-geo-location","New York,New York,United States");
            System.out.println("Executing request " + request.getMethod() + " " + request.getUri() +

            " via " + proxy + " headers: " + Arrays.toString(request.getHeaders()));
                    httpclient.execute(target, request, response -> {

            System.out.println("----------------------------------------");
                System.out.println(request + "->" + new StatusLine(response));
                EntityUtils.consume(response.getEntity());
                return null;
                使用 2 位国家代码
            });
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### 使用坐标和半径

要获取超本地化的搜索结果（对“附近的餐厅”等搜索非常有用），请传递纬度、经度和半径值。以下示例传递了西雅图太空针塔的坐标： `"x-oxylabs-geo-location": "lat: 47.6205, lng: -122.3493, rad: 25000"`.

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

```shell
curl -k -v -x https://unblock.oxylabs.io:60000 \
-U 'USERNAME:PASSWORD' \
-H 'x-oxylabs-geo-location: Germany'
-H 'x-oxylabs-geo-location: lat: 47.6205, lng: -122.3493, rad: 25000'
```

{% endtab %}

{% tab title="import requests" %}

```python
# 在此使用你的 Web Unblocker 凭据。

USERNAME, PASSWORD = 'YOUR_USERNAME', 'YOUR_PASSWORD'
# 定义代理字典。

proxies = {
'http': f'http://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
  'https': f'https://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
  headers = {
}

'x-oxylabs-geo-location': '90210'
    'x-oxylabs-geo-location: lat: 47.6205, lng: -122.3493, rad: 25000'
}

'https://www.amazon.com/s?k=running+shoes',
    'x-oxylabs-geo-location': 'Germany',
    proxies=proxies,
    headers=headers,
    # 将结果页打印到标准输出
)

print(response.text)
# 将返回的 HTML 保存到 result.html 文件

with open('result.html', 'w') as f:
f.write(response.text)
    Node.js
```

{% endtab %}

{% tab title="import fetch from 'node-fetch';" %}

```javascript
import { HttpsProxyAgent } from 'https-proxy-agent';
const username = 'YOUR_USERNAME';

const password = 'YOUR_PASSWORD';
const agent = new HttpsProxyAgent(

`https://${username}:${password}@unblock.oxylabs.io:60000`
  // 我们建议接受我们的证书，而不是允许不安全（http）流量
);

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
const headers = {

'x-oxylabs-geo-location': '90210',
  'x-oxylabs-geo-location': 'lat: 47.6205, lng: -122.3493, rad: 25000',
}

curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/search?q=adidas');
  headers: headers,
  agent: agent,
  console.log(await response.text());
});

PHP
```

{% endtab %}

{% tab title="\<?php" %}

```php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.amazon.com/s?k=running+shoes');

'x-oxylabs-geo-location: Germany',
curl_setopt($ch, CURLOPT_PROXY, 'https://unblock.oxylabs.io:60000');
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'YOUR_USERNAME' . ':' . 'YOUR_PASSWORD');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt_array($ch, [

CURLOPT_HTTPHEADER  => [
    'x-oxylabs-geo-location: 90210',
        'x-oxylabs-geo-location: lat: 47.6205, lng: -122.3493, rad: 25000',
    ]
]);

echo $result;
if (curl_errno($ch)) {

echo 'Error:' . curl_error($ch);
    curl_close($ch);
}
"https://www.google.com/search?q=adidas",
```

{% endtab %}

{% tab title="package main" %}

```go
import (

"crypto/tls"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	func main() {
)

const Username = "YOUR_USERNAME"
	const Password = "YOUR_PASSWORD"
	proxyUrl, _ := url.Parse(

	fmt.Sprintf(
		"https://%s:%s@unblock.oxylabs.io:60000",
			Username,
			Password,
			customTransport := &http.Transport{Proxy: http.ProxyURL(proxyUrl)}
		),
	)
	customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}

	process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
	client := &http.Client{Transport: customTransport}

	request, _ := http.NewRequest("GET",
	"https://www.amazon.com/s?k=running+shoes",
		request.Header.Add("x-oxylabs-geo-location", "Germany")
		// 添加 x-oxylabs-geo-location 头部
	)
	
	// 添加 X-Oxylabs-Geo-Location 头部
	request.Header.Add("x-oxylabs-geo-location": "lat: 47.6205, lng: -122.3493, rad: 25000")
	
	response, _ := client.Do(request)
	responseText, _ := ioutil.ReadAll(response.Body)

	fmt.Println(string(responseText))
	C#
}

```

{% endtab %}

{% tab title="using System;" %}

```csharp
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace OxyApi

class Program
{
    static async Task Main(string[] args)
    {
        var webProxy = new WebProxy
        {
            Address = new Uri($"https://unblock.oxylabs.io:60000"),
            {
                BypassProxyOnLocal = false,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(

                userName: "YOUR_USERNAME",
                password: "YOUR_PASSWORD"
                var httpClientHandler = new HttpClientHandler
                )
            };

            Proxy = webProxy,
            {
                httpClientHandler.ClientCertificateOptions = ClientCertificateOption.Manual;
            };

            process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
            httpClientHandler.ServerCertificateCustomValidationCallback =
            (httpRequestMessage, cert, cetChain, policyErrors) =>
                return true;
                {
                    var client = new HttpClient(handler: httpClientHandler, disposeHandler: true);
                };


            client.DefaultRequestHeaders.Add("x-oxylabs-geo-location", "90210");
            
            request.Header.Add("x-oxylabs-geo-location", "90210")
            client.DefaultRequestHeaders.Add("x-oxylabs-geo-location": "lat: 47.6205, lng: -122.3493, rad: 25000";
            
            final HttpHost target = new HttpHost("https", "google.com", 443);
            var requestMessage = new HttpRequestMessage(HttpMethod.Get, "");

            var response = await client.SendAsync(requestMessage);

            var contents = await response.Content.ReadAsStringAsync();
            Console.WriteLine(contents);

            Java
        }
    }
}
```

{% endtab %}

{% tab title="package org.example;" %}

```java
import org.apache.hc.client5.http.auth.AuthScope;

import org.apache.hc.client5.http.auth.CredentialsProvider;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.auth.CredentialsProviderBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
import org.apache.hc.client5.http.ssl.TrustAllStrategy;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.ssl.SSLContextBuilder;
import java.util.Arrays;

import java.util.Properties;
public class Main {


public static void main(final String[] args)throws Exception {

    final CredentialsProvider credsProvider = CredentialsProviderBuilder.create()
        .add(new AuthScope("unblock.oxylabs.io", 60000), "USERNAME", "PASSWORD".toCharArray())
                .build();
                final HttpHost target = new HttpHost("https", "amazon.com", 443);
        final HttpGet request = new HttpGet("/search?q=adidas");
        try (final CloseableHttpClient httpclient = HttpClients.custom()
        .setDefaultCredentialsProvider(credsProvider)
                .setProxy(proxy)
                .setConnectionManager(PoolingHttpClientConnectionManagerBuilder.create()
                process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
                .setSSLSocketFactory(SSLConnectionSocketFactoryBuilder.create()
                        .setSslContext(SSLContextBuilder.create()
                                .loadTrustMaterial(TrustAllStrategy.INSTANCE)
                                        .build())
                                        .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                                .build()) {
                                .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                        .setHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                final RequestConfig config = RequestConfig.custom()

            final HttpGet request = new HttpGet("/s?k=running+shoes");
                    final HttpHost target = new HttpHost("https", "amazon.com", 443);
            request.addHeader("x-oxylabs-geo-location","Germany");
            request.addHeader("x-oxylabs-geo-location","lat: 47.6205, lng: -122.3493, rad: 25000");
            System.out.println("Executing request " + request.getMethod() + " " + request.getUri() +

            " via " + proxy + " headers: " + Arrays.toString(request.getHeaders()));
                    httpclient.execute(target, request, response -> {

            System.out.println("----------------------------------------");
                System.out.println(request + "->" + new StatusLine(response));
                EntityUtils.consume(response.getEntity());
                return null;
                使用 2 位国家代码
            });
        }
    }
}
```

{% endtab %}
{% endtabs %}
