IP 控制
关于如何通过轮换代理更换 IP,以及如何使用静态 IP 保持相同 IP 的说明。
代理轮换
数据中心代理支持代理轮换。要使用此功能,您需要使用端口号 8000。每次新请求您将使用一个 随机 IP。
代码示例
curl -x dc.oxylabs.io:8000 -U "user-USERNAME:PASSWORD" https://ip.oxylabs.io/location #pip install requests
import requests
username = 'USERNAME'
password = 'PASSWORD'
proxy = 'dc.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)//npm install axios
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: "dc.oxylabs.io",
port: 8000,
auth: {
username: `user-${username}`,
password: password,
},
},
})
.then((res) => {
console.log(res.data);
})
.catch((err) => console.error(err));
静态会话
根据您的计费类型,您可以使用特定端口为请求保持一致的 IP 地址。
按 IP 的数据中心代理
对于按 IP 付费的计费类型,请使用特定的静态端口进行请求。您可以在您的 代理列表.
下面示例使用端口(8001)用于静态会话:
curl -x dc.oxylabs.io:8001 -U user-USERNAME:PASSWORD https://ip.oxylabs.io/location 在下面可以找到其他编程语言的更多代码示例:
curl -x dc.oxylabs.io:8001 -U user-USERNAME:PASSWORD https://ip.oxylabs.io/location #pip install requests
import requests
username = 'USERNAME'
password = 'PASSWORD'
proxy = 'dc.oxylabs.io:8001'
proxies = {
"https": ('https://user-%s:%s@%s' % (username, password, proxy))
}
response=requests.get("https://ip.oxylabs.io/location", proxies=proxies)
print(response.content)//npm install axios
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: "dc.oxylabs.io",
port: 8001,
auth: {
username: `user-${username}`,
password: password,
},
},
})
.then((res) => {
console.log(res.data);
})
.catch((err) => console.error(err));
有关在特定国家/地区使用轮换或静态会话,请参阅 选择国家 页面。
按流量的 数据中心代理
对于按流量计费类型,将使用范围内的一个静态端口 8001 to 63000 (在此范围内生成一个随机数)来发出请求。每次请求将从池中获得一个随机 IP, 但在会话期间该 IP 将保持一致。
下面是使用随机端口(35467)用于静态会话:
在下面可以找到其他编程语言的更多代码示例:
最后更新于
这有帮助吗?

