D
D
danis_20142018-06-05 01:39:01
Python
danis_2014, 2018-06-05 01:39:01

How to use authorization proxy in Selenium with Firefox in Python?

How to use authorized proxy with Selenium and Firefox in Python?
Here are the versions used:

  • Mozilla Firefox 60.0.1
  • geckodriver 0.10.0
  • selenium 3.12.0

Here is the code:
from selenium import webdriver

proxy_host = "196.19.8.88"
proxy_port = 8000

fp = webdriver.FirefoxProfile()
fp.set_preference("network.proxy.type", 1)
fp.set_preference("network.proxy.http", proxy_host)
fp.set_preference("network.proxy.http_port", proxy_port)
fp.set_preference("network.proxy.https", proxy_host)
fp.set_preference("network.proxy.https_port", proxy_port)
fp.set_preference("network.proxy.ssl", proxy_host)
fp.set_preference("network.proxy.ssl_port", proxy_port)
fp.set_preference("network.proxy.ftp", proxy_host)
fp.set_preference("network.proxy.ftp_port", proxy_port)
fp.set_preference("network.proxy.socks", proxy_host)
fp.set_preference("network.proxy.socks_port", proxy_port)
fp.update_preferences()

driver = webdriver.Firefox(firefox_profile=fp)
driver.get('http://www.myip.dk/')
print(driver.find_element_by_id('ipv4address').find_element_by_tag_name('p').text)
driver.quit()

It works with a proxy without authorization, but with authorization the following alert pops up:
5b15bf6b9bbd0863751583.png
How to pass authorization?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
danis_2014, 2018-06-14
@danis_2014

As a result, I decided to use a service that provides a proxy with binding to ip. That is, the need for authorization simply disappeared

D
Dimonchik, 2018-06-05
@dimonchik2013

Maybe it's easier to use Chrome? with the right user agent?
will be enough

service_args = [
        '--proxy=192.168.0.1:3128',
        '--proxy-auth=login:pass'
]

in FF dancing with a tambourine like addons

A
Andy_U, 2018-06-05
@Andy_U

Install cntlm.

E
Emil Revencu, 2018-06-14
@Revencu

Try to call url like:
http://[email protected]:196.19.8.88:8000

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question