#!/usr/bin/env python3 """ Netlify Farm — интерактивный запуск для новичка. Что делает: 1. спрашивает почту (один адрес или файл со списком), 2. спрашивает сколько аккаунтов, 3. сам берёт бесплатные прокси из пула iishko и проверяет их, 4. поднимает Chrome, регает аккаунты, создаёт сайт и деплой, 5. складывает результат в netlify_bank.jsonl и показывает таблицу. Запуск: python start.py Неинтерактивно: python start.py --mail-file mails.txt --count 3 --proxies auto --yes """ import argparse import json import os import shutil import subprocess import sys import time HERE = os.path.dirname(os.path.abspath(__file__)) PY = sys.executable BANK = os.path.join(HERE, 'netlify_bank.jsonl') CHROME_CANDIDATES = [ r'C:\Program Files\Google\Chrome\Application\chrome.exe', r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe', os.path.expandvars(r'%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe'), ] def say(msg=''): print(msg, flush=True) def find_chrome(): for c in CHROME_CANDIDATES: if c and os.path.exists(c): return c return '' def check_deps(): ok = True try: import playwright # noqa: F401 except Exception: say('[!] нет playwright. Поставь: pip install playwright') ok = False try: import httpx # noqa: F401 except Exception: say('[i] httpx нет — понадобится только для дашборда, не критично') if not find_chrome(): say('[!] Chrome не найден. Поставь Google Chrome.') ok = False return ok def ask(text, default=''): try: v = input(f'{text}' + (f' [{default}]' if default else '') + ': ').strip() except (EOFError, KeyboardInterrupt): say('\nотмена') sys.exit(1) return v or default def normalize_mail_line(line): line = line.strip() if not line or line.startswith('#'): return '' if ':' not in line: return '' return line def build_mail_file(single_or_path, workdir): """Return path to a pool file. Accepts email:pass or a path to a file.""" src = single_or_path.strip() if os.path.exists(src): return os.path.abspath(src) line = normalize_mail_line(src) if not line: return '' out = os.path.join(workdir, 'mails_input.txt') with open(out, 'w', encoding='utf-8') as f: f.write(line + '\n') return out def kill_chrome(): try: subprocess.run('taskkill /F /IM chrome.exe /T', shell=True, capture_output=True, timeout=30, env={**os.environ, 'MSYS_NO_PATHCONV': '1'}) except Exception: pass def launch_chrome(port, profile, proxy=''): chrome = find_chrome() if not chrome: return False args = [chrome, f'--remote-debugging-port={port}', f'--user-data-dir={profile}', '--no-first-run', '--no-default-browser-check', '--disable-blink-features=AutomationControlled'] if proxy: args.append(f'--proxy-server={proxy}') args.append('about:blank') subprocess.Popen(args, env=dict(os.environ)) import urllib.request for _ in range(20): time.sleep(1.5) try: urllib.request.urlopen(f'http://127.0.0.1:{port}/json/version', timeout=2).close() return True except Exception: continue return False def show_bank(limit=20): if not os.path.exists(BANK): say('банк пуст') return rows = [] with open(BANK, encoding='utf-8', errors='ignore') as f: for line in f: line = line.strip() if line: try: rows.append(json.loads(line)) except Exception: pass say('') say(f'{"email":<38} {"site":<34} token') say('-' * 90) for r in rows[-limit:]: say(f'{r.get("email",""):<38} {r.get("site_domain") or "-":<34} {str(r.get("token"))[:10]}...') say('') say(f'всего аккаунтов в банке: {len(rows)} -> {BANK}') def main(): ap = argparse.ArgumentParser(add_help=True) ap.add_argument('--mail', help='email:password или путь к файлу пула') ap.add_argument('--count', type=int, default=0) ap.add_argument('--proxies', default='', help="auto | файл | off") ap.add_argument('--site', dest='site', action='store_true', default=None) ap.add_argument('--no-site', dest='site', action='store_false') ap.add_argument('--port', type=int, default=9233) ap.add_argument('--yes', action='store_true', help='без вопросов') a = ap.parse_args() say('=' * 60) say(' NETLIFY FARM — авторегистрация аккаунтов') say('=' * 60) say('') if not check_deps(): say('') say('Установи зависимости и запусти снова:') say(' pip install playwright') sys.exit(1) mail_src = a.mail or ('' if a.yes else ask('Почта: один адрес email:pass или путь к файлу со списком')) if not mail_src: say('[!] без почты никак: нужен рабочий ящик с IMAP') sys.exit(1) mail_file = build_mail_file(mail_src, HERE) if not mail_file: say('[!] не понял почту. Формат: адрес:пароль либо путь к файлу') sys.exit(1) count = a.count if not count: raw = '1' if a.yes else ask('Сколько аккаунтов сделать', '1') try: count = int(raw) except ValueError: count = 1 proxies = a.proxies if not proxies: if a.yes: proxies = 'auto' else: ans = ask('Использовать бесплатные прокси из пула iishko? (да/нет)', 'да').lower() proxies = 'auto' if ans in ('да', 'д', 'y', 'yes', '1', '') else 'off' if proxies.lower() in ('off', 'нет', 'no', 'n'): proxies = '' site = a.site if site is None: site = True if a.yes else ask('Создавать сайт на каждом аккаунте? (да/нет)', 'да').lower() in ('да', 'д', 'y', 'yes', '1', '') say('') say('--- план ---') say(f' почты: {mail_file}') say(f' аккаунтов: {count}') say(f' прокси: {proxies or "без прокси (домашний IP)"}') say(f' сайт: {"да" if site else "нет"}') say('') # Chrome / профиль profile = os.path.join(HERE, '_chrome_profile') if proxies: say('[*] беру прокси из пула iishko...') try: sys.path.insert(0, HERE) from proxy_source import ProxyPool pool = ProxyPool(limit=60, check=8) first = pool.take() say(f'[i] рабочих прокси: {len(pool)}') except Exception as e: say(f'[!] пул прокси недоступен ({str(e)[:60]}), иду напрямую') proxies, first = '', '' else: first = '' say('[*] поднимаю Chrome...') kill_chrome() time.sleep(2) if not launch_chrome(a.port, profile): say('[!] Chrome не поднялся. Закрой все окна Chrome и запусти снова.') sys.exit(1) say('[i] Chrome готов') cmd = [PY, os.path.join(HERE, 'netlify_farm.py'), '--count', str(count), '--mails', mail_file, '--bank', BANK, '--port', str(a.port), '--profile', profile, '--captcha', 'auto'] if site: cmd.append('--site') if proxies: cmd += ['--proxies', proxies] say('') say('[*] поехали. Это займёт ~1-2 минуты на аккаунт') say('') env = dict(os.environ) env.pop('PYTHONPATH', None) env['PYTHONIOENCODING'] = 'utf-8' try: subprocess.run(cmd, cwd=HERE, env=env) except KeyboardInterrupt: say('\n[!] остановлено пользователем') show_bank() say('') say('Готово. Следующий раз просто: python start.py') say('Панель со статусами: python dashboard.py --port 8791 -> http://127.0.0.1:8791/') if __name__ == '__main__': main()