使用白名单 IP 的请求
使用白名单 IP,您可以访问 Oxylabs 住宅代理 (Residential Proxies) 而无需提供 用户名 和 密码。通过将您的 IP 地址加入白名单,您可以直接在子域中指定所有代理参数 。
如果您将某个 IP 添加到白名单,您应使用 要么白名单 IP 要么凭据,但不要同时使用两者,因为那样可能导致意外行为。
代码示例
下面是一个针对纽约市并使用给定会话 ID 的示例代码:
curl -x https://cc-us-city-new_york-sessid-test123.bc.pr.oxylabs.io:7777 https://ip.oxylabs.io/location<?php
$session_id = 'test123'; // 您的会话 ID
$city = 'new_york'; // 您要定位的城市
$proxy = "cc-us-city-$city-sessid-$session_id.bc.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");
$output = curl_exec($query);
curl_close($query);
if ($output)
echo $output;
?>
import urllib.request
session_id = 'test123' # 您的会话 ID
city = 'new_york' # 您要定位的城市
proxy = 'cc-us-city-%s-sessid-%s.bc.pr.oxylabs.io:7777' % (city, session_id)
query = urllib.request.ProxyHandler({
'http': proxy,
'https': proxy,
})
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("cc-us-city-new_york-sessid-test123.bc.pr.oxylabs.io", 7777);
String query = Executor.newInstance()
.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("cc-us-city-new_york-sessid-test123.bc.pr.oxylabs.io:7777");
Console.WriteLine(client.DownloadString("https://ip.oxylabs.io/location"));
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
func main() {
proxyURL, _ := url.Parse("https://cc-us-city-new_york-sessid-test123.bc.pr.oxylabs.io:7777")
client := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}}
resp, err := client.Get("https://ip.oxylabs.io/location")
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}查询参数
cc
不区分大小写的 2 字母国家代码 3166-1 alpha-2 格式。例如, DE 代表德国, GB 代表英国, TH 代表泰国。您可以在此处找到有关如何使用特定国家代理的更多详细信息 此处.
city
不区分大小写的英文城市名称。此参数必须与 cc 配合使用以获得更高准确性,例如, cc-GB-city-london 代表英国伦敦; cc-DE-city-berlin 代表德国柏林。对于由两个以上单词组成的城市,请将空格替换为 _,例如, city-st_petersburg 或 city-rio_de_janeiro。点击 此处 以获取有关城市级别定位的更多信息。
st
不区分大小写且以 us_ 开头的美国州名称,例如, us_california, us_illinois. 点击此处 以获取有关州级别定位的更多信息。
cn
要获取来自任一大洲的代理,请在授权字符串中添加 cn- 参数和两字母代码。有关大陆级别定位的更多信息,请点击此处
postalcode
要使用邮政编码连接代理,请添加并指定 postalcode 参数并提供一个 五位数 邮政编码。该参数必须与国家代码参数结合使用,且国家代码为不区分大小写的 2 字母格式, cc 在此了解更多信息。 3166-1 alpha-2 格式.
在此了解更多信息。
ASN
您可以选择来自特定运营商的代理。您必须在请求中输入所需的 ASN 编号。 在此了解更多信息。.
sessid
会话 ID,用于在后续查询中保持相同 IP。会话在 10 分钟后过期。之后,该会话 ID 会被分配到新的 IP 地址。支持随机字符串、0-9 和 A-Z 字符。
sesstime
会话时长参数可在一定时间内保持相同 IP。最大会话时长为 30 分钟。
最后更新于
这有帮助吗?

