Skip to content

Instantly share code, notes, and snippets.

@geekykant
Created October 8, 2020 14:23
Show Gist options
  • Save geekykant/9eefaa9de5909a07825c6f7f145f7f4d to your computer and use it in GitHub Desktop.
Save geekykant/9eefaa9de5909a07825c6f7f145f7f4d to your computer and use it in GitHub Desktop.
Generate Proxy using SSLProxies.org
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