代理轮换器 - 可选
了解代理轮换器,它作为轮换端点的功能及其会话控制特性。
代码示例
curl -x vm.oxylabs.io:60000 -U user1:pass1 https://ip.oxylabs.io/location<?php
$query = curl_init('https://ip.oxylabs.io/location');
curl_setopt($query, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($query, CURLOPT_PROXY, 'http://vm.oxylabs.io:60000');
curl_setopt($query, CURLOPT_PROXYUSERPWD, "username:password");
$output = curl_exec($query);
curl_close($query);
if ($output) {
echo $output;
}import requests
response = requests.get(
'https://ip.oxylabs.io/location',
proxies={'http': 'http://user1:[email protected]:60000',
'https': 'http://user1:[email protected]:60000'}
)
print(response.text)using System;
using System.Net;
class Example
{
static void Main()
{
var proxy = new WebProxy
{
Address = new Uri($"http://vm.oxylabs.io:60000"),
BypassProxyOnLocal = false,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("username", "password")
};
var handler = new HttpClientHandler
{
Proxy = proxy,
};
HttpClient client = new HttpClient(handler);
var task = Task.Run(async () =>
{
var response = await client.GetAsync("https://ip.oxylabs.io/location");
var content = response.Content;
var result = await content.ReadAsStringAsync();
return result;
});
task.Wait();
Console.WriteLine(task.Result);
}
}使用 Proxy Rotator 的会话控制
代码示例
user1@machine:~$ curl -x vm.oxylabs.io:60000 -U user1:pass1 https://ip.oxylabs.io/location --proxy-header "Proxy-Server: s10"
1.2.30.40
user1@machine:~$ curl -x vm.oxylabs.io:60000 -U user1:pass1 https://ip.oxylabs.io/location --proxy-header "Proxy-Server: s10"
1.2.30.40
user1@machine:~$ curl -x vm.oxylabs.io:60000 -U user1:pass1 https://ip.oxylabs.io/location --proxy-header "Proxy-Server: s10"
1.2.30.40<?php
$query = curl_init('https://ip.oxylabs.io/location');
curl_setopt($query, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($query, CURLOPT_PROXY, 'http://vm.oxylabs.io:60000');
curl_setopt($query, CURLOPT_PROXYUSERPWD, "username:password");
curl_setopt($query, CURLOPT_PROXYHEADER, [
"Proxy-Server: s10",
]);
$output = curl_exec($query);
curl_close($query);
if ($output) {
echo $output;
}import requests
class ProxyAdapter(requests.adapters.HTTPAdapter):
def proxy_headers(self, proxy):
headers = super(ProxyAdapter, self).proxy_headers(proxy)
headers['Proxy-Server'] = 's10'
return headers
s = requests.Session()
s.proxies = {'http': 'http://username:[email protected]:60000',
'https': 'http://username:[email protected]:60000'}
s.mount('http://', ProxyAdapter())
s.mount('https://', ProxyAdapter())
response = s.get('https://ip.oxylabs.io/location')
print(response.text)最后更新于
这有帮助吗?

