本示例演示如何使用 IPWO 动态住宅代理 通过 账密认证方式Node.js 中发送 HTTP 请求

// 引入 node-fetch,用于发送 HTTP 请求
import fetch from 'node-fetch';
// 引入 https-proxy-agent,用于创建代理对象
import createHttpsProxyAgent from 'https-proxy-agent'

// 设置IPWO的子账号
const username = 'username_custom_zone_us';
// 设置IPWO子账号的密码
const password = 'password';
// 设置 IPWO 代理服务器的地址及端口
const proxy = 'us.ipwo.net:7878'

// 创建一个代理对象,包含了代理认证信息(用户名:密码@IP:端口)
const agent = createHttpsProxyAgent(
  \`http://${username}:${password}@${proxy}\`
);

// 发送 GET 请求到目标网址(此处以 ipinfo.io 为例)
const response = await fetch('http://ipinfo.io', {
  method: 'get',
  agent: agent, // 使用刚才创建的代理对象
});

// 输出响应内容,通常返回 IP 信息
console.log(await response.text());

 

常见问题

汇总产品使用中常见技术问题、操作指南及功能说明,提供专业解答,助您快速掌握产品特性并优化使用体验。

查看更多 右箭头
新用户专享
注册领取 500M 免费测试
9000万+纯净高质代理池,助力您实现业务目标!