Skip to content

Instantly share code, notes, and snippets.

@optionsx
Last active May 30, 2023 02:07
Show Gist options
  • Save optionsx/6016c22089d73133b5f576d668271ee8 to your computer and use it in GitHub Desktop.
Save optionsx/6016c22089d73133b5f576d668271ee8 to your computer and use it in GitHub Desktop.
grab all archived proxies of checkerProxy.net site to run it: deno run -A https://gist.githubusercontent.com/optionsx/6016c22089d73133b5f576d668271ee8/raw/checkerProxy.ts
import { appendFileSync } from "node:fs";
type Proxy = {
addr: string;
ip_geo_country: string;
ip_geo_iso: string;
ip_geo_city: string;
type: number;
};
const headers = {
Accept: "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.9",
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.57",
};
class LabRat {
constructor() {}
async getProxie(url: string) {
const res = await fetch(url, { headers });
const proxies: Proxy[] = await res.json();
return { proxies, count: proxies.length };
}
regex = /<a[^>]*href="\/archive\/(.*?)"/g;
async extractHrefLinks() {
const _html = await fetch("https://checkerproxy.net/getAllProxy", {
headers,
}),
html = await _html.text();
const links = [];
let match;
while ((match = this.regex.exec(html)) !== null) {
links.push("https://checkerproxy.net/api/archive/" + match[1]);
}
return links;
}
async main() {
try {
Deno.removeSync("proxies.txt");
Deno.removeSync("SOCKS5.txt");
Deno.removeSync("HTTPS.txt");
Deno.removeSync("HTTP.txt");
} catch (e) {}
const links = await this.extractHrefLinks();
for (const link of links) {
await new Promise((resolve) => setTimeout(resolve, 1000));
const { proxies, count } = await this.getProxie(link);
console.log(`Got ${count} proxies from ${link}`);
proxies.filter((x) => {
appendFileSync("proxies.txt", `${x.addr}\n`);
if (x.type === 4) appendFileSync("SOCKS5.txt", `${x.addr}\n`);
if (x.type === 2) appendFileSync("HTTPS.txt", `${x.addr}\n`);
if (x.type === 1) appendFileSync("HTTP.txt", `${x.addr}\n`);
});
}
}
}
const labRat = new LabRat();
labRat.main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment