Problems with request Module testing HTTP proxy address

Code first

const proxys = [{
    type:"HTTP",
    ip:123.456.789.123
    port:4399
}]
function check() {
    let flag = proxys.length; 
    return new Promise((resolve, reject) => {
        for (let i = 0; i < proxys.length; iPP) {
            let proxy = proxys[i];
            request({
                url: "http://bbs.qcloud.com/forum-74-1.html",
                proxy: `${proxy.type.toLowerCase()}://${proxy.ip}:${proxy.port}`,
                method: "GET",
                timeout: 1000,
                headers: {
                    "User-Agent": UserAgent[Math.floor(Math.random() * UserAgent.length + 1) - 1]
                }
            }, function(error, response, body) {
                if (!error && response.statusCode == 200) {
                    useful.push(response.request["proxy"]["href"]);
                    console.log("");
                }
                flag--;
                if (flag == 0) {
                    resolve(useful);
                }
            });
        }
    }).then(res => {
        return JSON.stringify(res);
    }).catch(err => {
        return err;
    })
}

I want to test whether the http proxy address is available in the proxys array.
fill in the available address obtained by the above function into the browser for testing, and find that in the case of
Fu-Lq4Qv1atZqeOzKD3lbu5aYdeq

as shown below. The link request for

https failed. The link to
http redirects to the home page of youdao (www.youdao.com) and shows the authentication failure.
do you have any good solutions that allow me to filter out the available proxy addresses?

Mar.21,2021

thought of a solution for himself. Just verify that the content returned by the request is consistent with the original content. Url sets up an interface on its own server and returns the number 1. As long as you judge whether the returned content is 1 or not, you can determine whether the agent can be used or not.

Menu