Files
minara-autoreg/domain_probe.py
T

122 lines
4.2 KiB
Python

#!/usr/bin/env python3
"""Бесплатная проверка: какие домены minara ещё принимает.
Хитрость: с заведомо неверным captchaToken сервер отвечает
"Invalid captcha" -> домен ПРОШЁЛ фильтр (капчу решаем отдельно)
"not a valid domain" -> домен в чёрном списке (регистрация невозможна)
Капча при этом не тратится: до 2captcha дело не доходит.
usage: python domain_probe.py [--limit=N] [--workers=8] [--pool=pool_mix.jsonl]
out: domains_ok.jsonl / domains_dead.jsonl
"""
import argparse
import collections
import io
import json
import os
import sys
import threading
import requests
HERE = os.path.dirname(os.path.abspath(__file__))
API = "https://api.minara.ai"
H = {"Origin": "https://minara.ai", "Referer": "https://minara.ai/",
"Content-Type": "application/json", "User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36"}
LOCK = threading.Lock()
PROXIES = [p.strip() for p in os.environ.get("MINARA_PROXIES", "").split(",") if p.strip()]
_PI = [0]
def next_proxy():
if not PROXIES:
return None
with LOCK:
p = PROXIES[_PI[0] % len(PROXIES)]
_PI[0] += 1
return {"http": p, "https": p}
def probe(domain):
try:
r = requests.post(API + "/auth/email/code",
json={"email": "probe1@" + domain, "captchaToken": "x"},
headers=H, timeout=25, proxies=next_proxy())
body = (r.text or "").lower()
if "not a valid domain" in body:
return domain, "dead", r.status_code
if "invalid captcha" in body or "captcha" in body:
return domain, "ok", r.status_code
if r.status_code == 429:
return domain, "ratelimit", r.status_code
return domain, "other:" + (r.text or "")[:60], r.status_code
except Exception as e:
return domain, "err:" + str(e)[:40], 0
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--limit", type=int, default=0)
ap.add_argument("--workers", type=int, default=8)
ap.add_argument("--pool", default=os.path.join(HERE, "pool_mix.jsonl"))
a = ap.parse_args()
doms = []
with io.open(a.pool, encoding="utf8", errors="ignore") as fh:
for l in fh:
l = l.strip()
if not l:
continue
try:
d = json.loads(l).get("dom")
except Exception:
continue
if d and d not in doms:
doms.append(d)
if a.limit:
doms = doms[:a.limit]
print("доменов на пробу:", len(doms), flush=True)
c = collections.Counter()
ok, dead, other = [], [], []
lock = threading.Lock()
queue = list(doms)
queue.reverse()
def work():
while True:
with lock:
if not queue:
return
d = queue.pop()
dom, verdict, code = probe(d)
with lock:
c[verdict.split(":")[0]] += 1
if verdict == "ok":
ok.append(dom)
print("OK ", dom, flush=True)
elif verdict == "dead":
dead.append(dom)
else:
other.append((dom, verdict))
print("??? ", dom, verdict, flush=True)
ths = [threading.Thread(target=work) for _ in range(a.workers)]
for t in ths:
t.start()
for t in ths:
t.join()
with io.open(os.path.join(HERE, "domains_ok.jsonl"), "w", encoding="utf8", newline="\n") as fh:
for d in ok:
fh.write(json.dumps({"dom": d}, ensure_ascii=False) + "\n")
with io.open(os.path.join(HERE, "domains_dead.jsonl"), "w", encoding="utf8", newline="\n") as fh:
for d in dead:
fh.write(json.dumps({"dom": d}, ensure_ascii=False) + "\n")
print("итог: ok=%d dead=%d other=%d" % (len(ok), len(dead), len(other)), flush=True)
print("ok-домены:", ", ".join(ok[:40]), flush=True)
if __name__ == "__main__":
sys.exit(main())