Упрости код но сохранив функционал и возможности, фичи: import requests
import time
from faker import Faker
import random
import string

# Функция для чтения списка прокси из файла
def read_proxies(file_path):
    with open(file_path, 'r') as f:
        proxies = [line.strip() for line in f.readlines()]
    return proxies

# Генерация случайного прокси-сервера из списка прокси-серверов
def generate_random_proxy(proxies):
    if proxies:
        return {'ip': random.choice(proxies)}  # Возвращаем словарь с ключом 'ip'
    else:
        return {'ip': '0.0.0.0'}  # Возвращаем пустой IP-адрес по умолчанию

# Генерация случайного IP-адреса
def generate_fake_ip():
    fake = Faker()
    return fake.ipv4()

# Генерация случайного устройства с реалистичным user agent string
def generate_fake_device():
    device_types = ['desktop', 'mobile', 'tablet']
    device_type = random.choice(device_types)

    if device_type == 'desktop':
        brands = ['Dell', 'HP', 'Lenovo', 'Acer', 'Asus']
        brand = random.choice(brands)
        models = ['Inspiron', 'ProBook', 'ThinkPad', 'Aspire', 'VivoBook']
        model = random.choice(models)
        os_types = ['Windows', 'MacOS']
        os_type = random.choice(os_types)
        os_versions = ['Windows 10', 'Windows 11', 'MacOS 11', 'MacOS 12']
        os_version = random.choice(os_versions)

        device = {
            'deviceType': device_type,
            'deviceBrand': brand,
            'deviceModel': model,
            'osType': os_type,
            'osVersion': os_version,
            'userAgent': generate_random_user_agent(device_type, brand, model, os_type, os_version)
        }

    elif device_type == 'mobile':
        brands = ['Apple', 'Samsung', 'Google', 'Xiaomi', 'Huawei']
        brand = random.choice(brands)
        models = ['iPhone', 'Galaxy', 'Pixel', 'Mi', 'Mate']
        model = random.choice(models)
        os_types = ['iOS', 'Android']
        os_type = random.choice(os_types)
        os_versions = ['iOS 15', 'Android 11', 'Android 12', 'Android 13', 'Android 14']
        os_version = random.choice(os_versions)

        device = {
            'deviceType': device_type,
            'deviceBrand': brand,
            'deviceModel': model,
            'osType': os_type,
            'osVersion': os_version,
            'userAgent': generate_random_user_agent(device_type, brand, model, os_type, os_version)
        }

    elif device_type == 'tablet':
        brands = ['Apple', 'Samsung', 'Amazon']
        brand = random.choice(brands)
        models = ['iPad', 'Galaxy Tab', 'Kindle Fire']
        model = random.choice(models)
        os_types = ['iOS', 'Android']
        os_type = random.choice(os_types)
        os_versions = ['iOS 15', 'Android 11', 'Android 12']
        os_version = random.choice(os_versions)

        device = {
            'deviceType': device_type,
            'deviceBrand': brand,
            'deviceModel': model,
            'osType': os_type,
            'osVersion': os_version,
            'userAgent': generate_random_user_agent(device_type, brand, model, os_type, os_version)
        }

    return device

# Генерация случайного user agent string
def generate_random_user_agent(device_type, brand, model, os_type, os_version):
    if device_type == 'desktop':
        if os_type == 'Windows':
            user_agent = f'Mozilla/5.0 (Windows NT {random.randint(10, 11)}; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{random.randint(80, 90)}.0.{random.randint(0, 9999)} Safari/537.36'
        elif os_type == 'MacOS':
            user_agent = f'Mozilla/5.0 (Macintosh; Intel Mac OS X {random.randint(10, 12)}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{random.randint(80, 90)}.0.{random.randint(0, 9999)} Safari/537.36'
    elif device_type == 'mobile':
        if os_type == 'iOS':
            user_agent = f'Mozilla/5.0 (iPhone; CPU iPhone OS {random.randint(13, 15)} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/{random.randint(80, 90)}.0.{random.randint(0, 9999)} Mobile/15E148 Safari/604.1'
        elif os_type == 'Android':
            user_agent = f'Mozilla/5.0 (Linux; Android {random.randint(10, 12)}; {random.choice(["Build/MOB30J", "Build/RP1A.201005.002", "Build/OPM2.180104.012"])} {random.choice(["SAMSUNG", "Google", "Xiaomi", "Huawei"])}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{random.randint(80, 90)}.0.{random.randint(0, 9999)} Mobile Safari/537.36'
    elif device_type == 'tablet':
        if os_type == 'iOS':
            user_agent = f'Mozilla/5.0 (iPad; CPU OS {random.randint(13, 15)} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/{random.randint(80, 90)}.0.{random.randint(0, 9999)} Mobile/15E148 Safari/604.1'
        elif os_type == 'Android':
            user_agent = f'Mozilla/5.0 (Linux; Android {random.randint(10, 12)}; Tablet {random.choice(["Build/MOB30J", "Build/RP1A.201005.002", "Build/OPM2.180104.012"])} {random.choice(["SAMSUNG", "Google", "Amazon"])}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{random.randint(80, 90)}.0.{random.randint(0, 9999)} Safari/537.36'

    return user_agent

# Пример использования сгенерированного IP-адреса и устройства
proxies_file_path = 'C:\\Users\\Wenorg\\Documents\\proxies.txt'
proxies = read_proxies(proxies_file_path)
for _ in range(10):
    proxy_type = random.choice(['socks5', 'http', 'https'])
    selected_proxy = generate_random_proxy(proxies)
    ip_address = selected_proxy['ip']
    if proxy_type == 'socks5':
        proxy = {'socks5': ip_address + ':443'}
    elif proxy_type == 'http':
        proxy = {'http': ip_address + ':80'}
    elif proxy_type == 'https':
        proxy = {'https': ip_address + ':443'}

    headers = {
        'User-Agent': random.choice([
            'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
            'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0',
            'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; InfoPath.3; rv:11.0) like Gecko',
            'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393'
        ])
    }

    fake = Faker()
    age = random.randint(18, 60)
    gender = random.choice(['Male', 'Female'])
    city = fake.city()
    country = fake.country()
    device = generate_fake_device()

    print(f"Random Data: Age - {age}, Gender - {gender}, City - {city}, Country - {country}, Device - {device}")

    def fetch_url(url, headers, proxy):
        try:
            response = requests.get(url, headers=headers, timeout=10, proxies=proxy)
            print(f"URL: {url} -> Status code: {response.status_code}")
        except Exception as e:
            print(f"URL: {url} -> Failed to fetch. Error: {e}")

    if __name__ == "__main__":
        url_list = [
            "https://vk.com/whatnewingames/",
            # Добавьте больше URL-адресов по мере необходимости
        ]

        while True:
            for url in url_list:
                headers = {
                    'Referer': 'https://ya.ru/',
                    'User-Agent': random.choice([
                        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
                        'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0',
                        'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; InfoPath.3; rv:11.0) like Gecko',
                        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393'
                    ])
                }
                proxy = generate_random_proxy(proxies)
                fetch_url(url, headers, proxy)

            time.sleep(60)