For the complete documentation index, see llms.txt. This page is also available as Markdown.

发起请求

了解如何通过用户名和密码身份验证使用独享数据中心代理发起请求。查找用于快速测试的代码示例。

向以下地址发出请求 https://ip.oxylabs.io/location 使用列表中的第一个 Dedicated Datacenter 代理。将 USERNAMEPASSWORD 替换为您的代理用户凭据。

使用 ip.oxylabs.io/location 用于检查您的 IP 参数——该域名提供来自四个地理定位数据库的信息:MaxMind、IP2Location、DB-IP 和 IPinfo.io。参数包括 IP 地址、提供商、国家/地区、城市、邮政编码、ASN、组织名称、时区和元信息(当数据库披露时)。

curl -x ddc.oxylabs.io:8001 -U "user-USERNAME:PASSWORD" https://ip.oxylabs.io/location 

请注意,您必须按照上面的示例构建用户名字符串,才能成功发出请求。将 user- 字符串添加到您的用户名中,并注意凭据区分大小写。

代码示例

curl -x ddc.oxylabs.io:8001 -U "user-USERNAME:PASSWORD" https://ip.oxylabs.io/location 
import requests

username = 'USERNAME'
密码 = 'PASSWORD'
proxy = 'ddc.oxylabs.io:8001'

代理 = {
   "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: "ddc.oxylabs.io",
            port: 8001,
            auth: {
                username: `user-${username}`,
                password: password,
            },
        },
    })
    .then((res) => {
        console.log(res.data);
    })
    .catch((err) => console.error(err));

您代理列表中的第一个 IP 将始终使用8001 端口。若要使用不同的代理发出请求,您需要找到您的 代理列表 并从那里取用端口值。

这有帮助吗?