代理轮换
了解如何为独享 ISP 代理启用代理轮换以及如何从特定国家池中轮换 IP。
Self-Service Dedicated ISP Proxies 支持自动代理轮换。要使用此功能,您需要将端口号更改为 8000。每次新请求时,您将从代理列表中收到一个随机 IP。
代码示例
curl -x disp.oxylabs.io:8000 -U "user-USERNAME:PASSWORD" https://ip.oxylabs.io/location import requests
username = 'USERNAME'
password = 'PASSWORD'
proxy = 'disp.oxylabs.io:8000'
proxies = {
"https": ('https://user-%s:%s@%s' % (username, password, proxy))
}
response=requests.get("https://ip.oxylabs.io/location", proxies=proxies)
print(response.content)const axios = require("axios");
const https = require("https");
const client = axios.create({
httpsAgent: new https.Agent({
rejectUnauthorized: false,
}),
});
const username = 'USERNAME';
const password = 'PASSWORD'
client
.get("https://ip.oxylabs.io/location", {
proxy: {
protocol: "https",
host: "disp.oxylabs.io",
port: 8000,
auth: {
username: `user-${username}`,
password: password,
},
},
})
.then((res) => {
console.log(res.data);
})
.catch((err) => console.error(err));
如果您提供一个 country- 参数,则 IP 将从指定的国家池中选择。例如,如果您只想轮换美国代理池,请使用一个参数 country- 并在您的用户字符串中添加两个字母的国家代码 country-US 在您的用户字符串中。
代码示例
curl -x https://disp.oxylabs.io:8000 -U 'user-USERNAME-country-COUNTRY:PASSWORD' https://ip.oxylabs.io/locationimport requests
username = 'USERNAME'
password = 'PASSWORD'
country = 'COUNTRY'
proxy = 'disp.oxylabs.io:8000'
proxies = {
"https": ('https://user-%s-country-%s:%s@%s' % (username, country, password, proxy))
}
response=requests.get("https://ip.oxylabs.io/location", proxies=proxies)
print(response.content)const axios = require("axios");
const https = require("https");
const client = axios.create({
httpsAgent: new https.Agent({
rejectUnauthorized: false,
}),
});
const username = 'USERNAME';
const country = 'COUNTRY'
const password = 'PASSWORD'
client
.get("https://ip.oxylabs.io/location", {
proxy: {
protocol: "https",
host: "disp.oxylabs.io",
port: 8000,
auth: {
username: `user-${username}-country-${country}`,
password: password,
},
},
})
.then((res) => {
console.log(res.data);
})
.catch((err) => console.error(err));
最后更新于
这有帮助吗?

