Created
October 8, 2020 14:23
-
-
Save geekykant/9eefaa9de5909a07825c6f7f145f7f4d to your computer and use it in GitHub Desktop.
Generate Proxy using SSLProxies.org
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function proxyGenerator() { | |
let ip_addresses = []; | |
let port_numbers = []; | |
return axios | |
.get("https://sslproxies.org/") | |
.then((response) => { | |
if (response.status == 200) { | |
let $ = cheerio.load(response.data); | |
$("td:nth-child(1)").each(function (index, _) { | |
ip_addresses[index] = $(this).text(); | |
}); | |
$("td:nth-child(2)").each(function (index, value) { | |
port_numbers[index] = $(this).text(); | |
}); | |
} else { | |
handleError("Error connecting to SSLProxies"); | |
} | |
ip_addresses.join(", "); | |
port_numbers.join(", "); | |
}) | |
.catch((error) => handleError(error)) | |
.then(() => { | |
let random_number = Math.floor(Math.random() * 100); | |
// let proxy = `http://${ip_addresses[random_number]}:${port_numbers[random_number]}`; | |
return [ip_addresses[random_number], port_numbers[random_number]]; | |
// return proxy; | |
}); | |
} | |
function handleError(error) { | |
console.log(error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment