Kodunuzda proxy ve user-agent seçiminde rastgelelik kullanılmış ve bu da bazı durumlarda aynı proxy veya user-agent'ın kullanılmasına neden olabilir. Bunun yerine proxy ve user-agent listesinden sıradaki elemanı seçmek için bir döngü kullanabilirsiniz. Aşağıdaki kod, bu yöntemi kullanarak proxy ve user-agent seçimini düzenlemiştir:

from seleniumwire import webdriver
import itertools
import time

# read proxy list from file
with open('proxy.txt', 'r') as f:
    proxy_list = f.read().splitlines()

# read user-agent list from file
with open('user.txt', 'r') as f:
    user_agent_list = f.read().splitlines()

# create a cycle iterator for proxies and user-agents
proxy_cycle = itertools.cycle(proxy_list)
user_agent_cycle = itertools.cycle(user_agent_list)

while True:
    # get the next proxy and user-agent
    proxy = next(proxy_cycle)
    user_agent = next(user_agent_cycle)

    # parse proxy information
    proxy_info = proxy.split(':')
    if len(proxy_info) == 4:
        # if username and password are included in the proxy string
        username = proxy_info[2]
        password = proxy_info[3]
        proxy_url = f"http://{username}:{password}@{proxy_info[0]}:{proxy_info[1]}"
    else:
        # if no username and password are included in the proxy string
        proxy_url = f"http://{proxy}"

    # create Chrome driver with selected proxy and user-agent
    options = {
        'proxy': {
            'http': proxy_url,
            'https': proxy_url,
            'no_proxy': 'localhost,127.0.0.1'  # exclude localhost from proxy
        },
        'headers': {
            'User-Agent': user_agent
        }
    }
    chrome = webdriver.Chrome(seleniumwire_options=options)

    chrome.get("https://www.example.com")

    time.sleep(10)

    # do whatever you need to do with the Chrome driver here

    # quit the driver
    chrome.quit()