提出请求
Last updated
Last updated
基本查询只需要传递 username
和 password
。不需要其他任何参数。此类查询中,将请求设为从随机 IP (代理)地址发出。每个新请求都使用不同的代理。
参数 | 描述 |
---|---|
- 必须提供的参数
在该示例中,从随机 IP 执行对 ipinfo.io/location
的查询:
curl -x dc.pr.oxylabs.io:10000 -U "customer-USERNAME:PASSWORD" https://ip.oxylabs.io/location
<?php
$username = 'USERNAME';
$password = 'PASSWORD';
$proxy = 'dc.pr.oxylabs.io:10000';
$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:$password");
$output = curl_exec($query);
curl_close($query);
if ($output)
echo $output;
?>
import urllib.request
import random
username = 'USERNAME'
password = 'PASSWORD'
entry = ('http://customer-%s:%s@dc.pr.oxylabs.io:10000' %
(username, 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/location", 7777);
String query = Executor.newInstance()
.auth(entry, "customer-USERNAME", "PASS")
.execute(Request.Get("http://icanhazip.com").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("dc.pr.oxylabs.io:10000");
client.Proxy.Credentials = new NetworkCredential("customer-USERNAME", "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', 'PASSWORD')
req = Net::HTTP::Get.new(uri.path)
result = proxy.start(uri.host,uri.port) do |http|
http.request(req)
end
puts result.body
customer
用户名
sessid
会话 ID 在接下来的查询中保留相同的 IP。会话不会过期 - 您可以无限期地保留它。随机字符串;支持 0-9、A-z 字符。
password
密码