9

I want to use Selenium Webdriver with a proxy which needs user authentication. Is this possible?

this is, what i have so far, but I don't know where to put the credentials ( user:pass@proxy:port)

from selenium import webdriver

profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", "proxy")
profile.set_preference("network.proxy.http_port", "port_number")
profile.update_preferences()
driver = webdriver.Firefox(firefox_profile=profile)
driver.get('http://www.google.com')
driver.title
3

1 Answer 1

-3

This is what I have been using without any issues, using Seleniums built in proxy capabilities.

from selenium import webdriver
from selenium.webdriver.common.proxy import *


prof = webdriver.FirefoxProfile()
prof.set_preference('signon.autologin.proxy', 'true')
prof.set_preference('network.proxy.share_proxy_settings', 'false')
prof.set_preference('network.automatic-ntlm-auth.allow-proxies', 'false')
prof.set_preference('network.auth.use-sspi', 'false')

proxy_data = {'address': '123.123.123.123:2345',
              'usernmae': 'johnsmith123',
              'password': 'iliketurtles'}

proxy_dict = {'proxyType': ProxyType.MANUAL,
              'httpProxy': proxy_data['address'],
              'ftpProxy': proxy_data['address'],
              'sslProxy': proxy_data['address'],
              'noProxy': '',
              'socksUsername': proxy_data['username'],
              'socksPassword': proxy_data['password']}

proxy_config = Proxy(proxy_dict)

driver = webdriver.Firefox(proxy=proxy_config, firefox_profile=prof)

EDIT: this answer was from 2017. Selenium and Firefox have both made major changes and it no longer works. hence why this answer went from 5 upvotes to now -3.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.