Selenium: connect through a proxy with a username/password- How?

124 views
Skip to first unread message

yoni keren

unread,
Jun 30, 2019, 7:34:07 AM6/30/19
to Selenium Users
There are lots of this exact same question ,but all of the answers are outdated,for example:

This is an outdated answer from 2016:
and another outdated answer from 2017:

Anyways, when I'm trying to use a proxy which required a username+password like so:

    from selenium import webdriver
    profile = webdriver.FirefoxProfile()
    profile.set_preference("network.proxy.type", 1)
    profile.set_preference("network.proxy.http", PROXY_HOST)
    profile.set_preference("network.proxy.http_port", PROXY_PORT)
    profile.set_preference("network.proxy.socks_username", USERNAME)
    profile.set_preference("network.proxy.socks_password", PASSWORD)
    profile.set_preference('network.proxy.ssl', PROXY_HOST)
    profile.set_preference('network.proxy.ssl_port', PROXY_PORT)
    
    profile.update_preferences()
    
    # executable_path  = define the path if u don't already have in the PATH system variable. 
    
    driver = webdriver.Firefox(firefox_profile=profile)
    page = driver.get('http://whatismyipaddress.com/')

It doesn't work at all.

What's the cleanest way which is actually working to connect through a proxy (given a username and a password as well) right now?

(Bonus points if you can explain why my code doesnt work-the fact it doesnt work makes no sense to me!)

Reply all
Reply to author
Forward
0 new messages