文章详情
接入指南 - 代码 - Nodejs - http
const http = require("http");
const url  = require("url");

// 要访问的目标页面
const targetUrl = "http://www.quqiquqi.com/test";
// 请求切换IP(仅短效版、长效版用。动态版每次请求自动切换,无需指定)
//const targetUrl = "http://www.quqiquqi.com/switch-ip";
// 查看当前隧道出口IP信息
//const targetUrl = "http://www.quqiquqi.com/current-ip";

const urlParsed   = url.parse(targetUrl);

// 代理服务器
const proxyHost = "tunnel.quqiquqi.com";
const proxyPort = "8600";

// 代理隧道验证信息
const proxyUser = "U123456789";
const proxyPass = "P123456789";

const base64    = new Buffer(proxyUser + ":" + proxyPass).toString("base64");

const options = {
    host    : proxyHost,
    port    : proxyPort,
    path    : targetUrl,
    method  : "GET",
    headers : {
        "Host"                : urlParsed.hostname,
        "Proxy-Authorization" : "Basic " + base64
    }
};

http
    .request(options, function(res) {
        console.log("got response: " + res.statusCode);
    })
    .on("error", function(err) {
        console.log(err);
    })
    .end()
;
发布时间:2021-10-02

在线客服