44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
"""Collect + validate free HTTP proxies against freemodel.in."""
|
|
import concurrent.futures as cf, json, re, sys
|
|
import requests
|
|
|
|
SRC = [
|
|
"https://api.proxyscrape.com/v4/free-proxy-list/get?request=display_proxies&protocol=http&proxy_format=ipport&format=text&timeout=8000",
|
|
"https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/http.txt",
|
|
"https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/http.txt",
|
|
"https://raw.githubusercontent.com/proxifly/free-proxy-list/main/proxies/protocols/http/data.txt",
|
|
]
|
|
|
|
def grab():
|
|
out = set()
|
|
for u in SRC:
|
|
try:
|
|
r = requests.get(u, timeout=25)
|
|
for m in re.findall(r"(\d{1,3}(?:\.\d{1,3}){3}:\d{2,5})", r.text):
|
|
out.add(m)
|
|
except Exception as e:
|
|
print("src fail", u[:40], str(e)[:60])
|
|
return out
|
|
|
|
def test(p, url="https://freemodel.in/register"):
|
|
px = {"http": "http://" + p, "https": "http://" + p}
|
|
try:
|
|
r = requests.get(url, proxies=px, timeout=12, headers={"User-Agent": "Mozilla/5.0"})
|
|
if r.status_code == 200 and "FreeModel" in r.text:
|
|
return p
|
|
except Exception:
|
|
return None
|
|
return None
|
|
|
|
if __name__ == "__main__":
|
|
cand = grab()
|
|
print("candidates", len(cand), flush=True)
|
|
ok = []
|
|
with cf.ThreadPoolExecutor(80) as ex:
|
|
for res in ex.map(test, list(cand)):
|
|
if res:
|
|
ok.append(res)
|
|
print("OK", res, flush=True)
|
|
open("px_ok.txt", "w").write("\n".join(ok))
|
|
print("alive", len(ok))
|