-
const request = require("request");
-
const targetUrl =
"https://ip.hahado.cn/ip";
-
const proxyIp =
"219.151.125.106";
-
const proxyPort =
31615;
-
const authKey =
"895314XY";
-
const password =
"24D6YB309ZCB";
-
const proxyUrl =
"http://"
+ authKey +
":"
+ password +
"@"
+ proxyIp +
":"
+ proxyPort;
-
const req = request.defaults({'proxy': proxyUrl});
-
const options =
{
-
url : targetUrl,
-
headers:
{}
-
};
-
req.get(options,
function
(err, resp, body)
{
-
if
(err)
{
-
return console.log(err);
-
}
-
console.log("response status code: "
+ resp.statusCode);
-
console.log("response body: "
+ body);
-
}).on("error",
function
(err)
{
-
console.log("request failed: "
+ err);
-
});
![Node语言代码示例nodejs request Node语言代码示例nodejs request](https://image.shishitao.com:8440/aHR0cHM6Ly9zMi41MWN0by5jb20vaW1hZ2VzLzIwMjIxMC83NThiMDAwNjA1NjExNWY3YThjMDM4NWRkZDY5ZWU3MzhmZGIzYS5wbmc%3D.png?w=700&webp=1)