Oxylabs Documentation
中文
搜索
K

选择国家/地区

住宅
移动
轮换 ISP
向授权头添加 cc 标志,可指定使用哪个国家/地区的 IP 处理请求。这个参数的值是一个不分大小写的国家代码,2 个字母 3166-1 alpha-2 格式。例如,DE 代表德国的代理,GB 代表英国的代理,TH 代表泰国的代理。请参阅示例了解详情。

代码示例

在该示例中,从德国的一个随机 IP 地址执行对 ipinfo.io 的查询:
cURL
PHP
Python
Java
C#
Ruby
curl -x pr.oxylabs.io:7777 -U "customer-USERNAME-cc-DE:PASSWORD" https://ip.oxylabs.io/location
<?php
$username = 'USERNAME';
$password = 'PASSWORD';
$country = 'DE';
$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-cc-$country:$password");
$output = curl_exec($query);
curl_close($query);
if ($output)
echo $output;
?>
import urllib.request
import random
username = 'USERNAME'
password = 'PASSWORD'
country = 'DE'
entry = ('http://customer-%s-cc-%s:%[email protected]:7777' %
(username, country, password))
query = urllib.request.ProxyHandler({
'http': entry,
'https': entry,
})
execute = urllib.request.build_opener(query)
print(execute.open('https://ip.oxylabs.io/location').read())
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-cc-DE", "PASS")
.execute(Request.Get("https://ip.oxylabs.io/location").viaProxy(entry))
.returnContent().asString();
System.out.println(query);
}
}
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-cc-DE", "PASSWORD");
Console.WriteLine(client.DownloadString("https://ip.oxylabs.io/location"));
}
}
require 'uri'
require 'net/http'
uri = URI.parse('https://ip.oxylabs.io/location')
proxy = Net::HTTP::Proxy('pr.oxylabs.io', 7777, 'customer-USERNAME-cc-DE', 'PASSWORD')
req = Net::HTTP::Get.new(uri.path)
result = proxy.start(uri.host,uri.port) do |http|
http.request(req)
end
puts result.body
最近更新 3mo ago