2

I am trying to add proxies in Firefox driver (which do have authentication). Though I set the proxy by the below code, it is not clear to add authentication for the proxies.

 myProxy = "xxx.xxx.xxx.xxx:80"

proxy = Proxy({
    'proxyType': ProxyType.MANUAL,
    'httpProxy': myProxy, 
    'ftpProxy': myProxy,  
    'sslProxy': myProxy,  
    'noProxy': ''
})

driver = webdriver.Firefox(proxy=proxy)

I have gone through this answer for authentication but it is also not working.

Any help will be appreciated.

Thanks in advance

5
  • What is the error that you are getting? Commented Jul 4, 2018 at 7:31
  • I did not get any error. While testing my proxy with whatismyip.com, I found that the proxy wasn't working as my system IP was shown there. Commented Jul 4, 2018 at 7:35
  • Did you try below code? Commented Jul 4, 2018 at 7:53
  • I am using Python. And you have given solution in Java itseems. I am trying to understand the code. Will try, Commented Jul 4, 2018 at 8:07
  • Ah okay. Yeah please change and see it it works. Commented Jul 4, 2018 at 8:08

1 Answer 1

1

Here is what I was (finally) able to get to work. I wasn't able to change the port - I didn't see anything to do that in the proxy.py file either, but I will admit I didn't look too hard since my proxies are on port 80 anyway.

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.proxy import Proxy

proxy_use= "xxx.xxx.xxx.xxx"
desired_capability = webdriver.DesiredCapabilities.FIREFOX
desired_capability['proxy'] = {
    'proxyType': "manual",
    'httpProxy': proxy_use,
    'ftpProxy': proxy_use,
    'sslProxy': proxy_use,
        }
queryURL = "https://insert.yourwebsitetocheckip.here"
browser = webdriver.Firefox(capabilities=desired_capability)
browser.get(queryURL)

I have my function doing a lot more than this, so I just pulled out the relevant part. Looking at this quickly you might not have to import Options - try it without and see if it works.

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

1 Comment

tried so many ways, this actaully work. thanks for this

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.