选择大洲
要从七大洲中获取代理,请在授权字符串中添加 cn-
参数和两个字母的代码。可选择的大洲列表及相应的字母代码如下:
cn-AF
代表非洲
cn-AN
代表南极洲
cn-AS
代表亚洲
cn-EU
代表欧洲
cn-NA
代表北美洲
cn-OC
代表大洋洲
cn-SA
代表南美洲
代码示例
在此示例中,从亚洲的随机IP地址执行了对 ip.oxylabs.io/location
的查询:
curl -x pr.oxylabs.io:7777 -U "customer-USERNAME-cn-AS:PASSWORD" https://ip.oxylabs.io/location
<?php
$username = 'USERNAME';
$password = 'PASSWORD';
$continent = 'AS';
$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-cn-$continent:$password");
$output = curl_exec($query);
curl_close($query);
if ($output)
echo $output;
?>
import urllib.request
import random
username = 'USERNAME'
password = 'PASSWORD'
continent = 'AS'
entry = ('http://customer-%s-cn-%s:%s@pr.oxylabs.io:7777' %
(username, continent, 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-cn-AS", "PASS")
.execute(Request.Get("http://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-cn-AS", "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-cn-AS', 'PASSWORD')
req = Net::HTTP::Get.new(uri.path)
result = proxy.start(uri.host,uri.port) do |http|
http.request(req)
end
puts result.body
Last updated