文章详情
接入指南 - 代码 - Nodejs - axios
const axios = require('axios');

// 要访问的目标页面
var targetUrl = "http://www.quqiquqi.com/test";

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

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

var proxy = {
    host: proxyHost,
    port: proxyPort,
    auth: {
        username: proxyUser,
        password: proxyPass
    }
};

// 参见官方文档 https://github.com/axios/axios#request-config
axios.get(targetUrl,{proxy:proxy})
    .then(function (response) {
        // handle success
        console.log(response.data);
    })
    .catch(function (error) {
        // handle error
        console.log(error);
    })
    .finally(function () {
        // always executed
    });              
        
发布时间:2021-10-02

在线客服