Sunday, 26 November 2023

Proxy won't connect after adding user directory and profile directory

I am having trouble connecting to this proxy with seleniumwire, it will connect and ask me for user and password if I remove this line. and yes, I have the actual directory and proxy in the real code, it is changed on here for privacy reasons.

chrome_options.add_argument(f'--profile-directory={profile_directory}')

I'm not sure if maybe the profile directory changes proxy or what but it will only connect if that is removed, how can I make it connect and still use the profile directory?

from seleniumwire import webdriver

proxy_address = "your_proxy_address:your_proxy_port"
user_data_dir = "path/to/your/user/data/directory"
profile_directory = "YourProfileDirectory"

chrome_options = webdriver.ChromeOptions()

proxy_options = {
    'proxy': {
        'http': f'http://{proxy_address}',
        'https': f'https://{proxy_address}',
        'no_proxy': 'localhost,127.0.0.1'
    }
}

chrome_options.add_argument(f'--user-data-dir={user_data_dir}')
chrome_options.add_argument(f'--profile-directory={profile_directory}')

driver = webdriver.Chrome(seleniumwire_options=proxy_options, chrome_options=chrome_options)


driver.get("https://myurl.com/")


from Proxy won't connect after adding user directory and profile directory

No comments:

Post a Comment