1

I have added proxy settings to the browser using below code:

proxyIP = 'some IP'
proxyPort = some_port

proxy_settings = {'network.proxy.type': 1,
       'network.proxy.http': proxyIP,
       'network.proxy.http_port': proxyPort,
       'network.proxy.ssl': proxyIP,
       'network.proxy.ssl_port':proxyPort,
       'network.proxy.socks': proxyIP,
       'network.proxy.socks_port':proxyPort,
       'network.proxy.ftp': proxyIP,
       'network.proxy.ftp_port':proxyPort           
      }

with Browser('firefox',profile_preferences=proxy_settings) as browser:

Firefox browser opens up & when I check the proxy settings, they are loaded with correct values. But it fails to load the url with browser.visit('https://www.google.com/') It throws the error:

TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

I even added 'accept_untrusted_certs': True in proxy_settings incase that would help. But to no avail.

If I manually enter a url in the browser-instance that gets created, it successfully visits the page.

  • Is something missing?
  • Is there a way to start the browser with its default profile (so that all proxy settings, extensions, etc. get loaded automatically)? I tried Browser(profile='profile_path'), it did not work out.

In hope...

P.S: The same code (without proxy settings) works perfectly well on a system with direct internet.

Mauricio
  • 43
  • 3
Rampy
  • 395
  • 1
  • 3
  • 13
  • well, you set the http proxy, but you're visiting a page with https. I think you need to set the https proxy too. – Roberto Dec 25 '14 at 07:00
  • @Roberto: I thought SSL with HTTP settings take care of HTTPS, no? Plus, these are the only options provided by firefox (or the ones that I am aware of). Is there a different setting that you are aware of, to explicitly set a HTTPS proxy? – Rampy Jan 07 '15 at 07:14
  • There should exist two separate settings... Specifically for Firefox, "This preference specifies the proxy server to use for the given protocol. Possible protocols: HTTP, HTTPS, FTP, Gopher, SOCKS" http://kb.mozillazine.org/Network.proxy.%28protocol%29#Firefox – Roberto Jan 07 '15 at 21:42
  • Did you try it, anyways? It's easier to try than to think about it :p `network.proxy.https': proxyIP,` `network.proxy.https_port': proxyPort,` – Roberto Jan 07 '15 at 21:43
  • Hey @Roberto, thanks for the response & persuasion. HTTPS from the list of protocols is handled by HTTP & SSL setting. Nevertheless, I tried `network.proxy.https` & `network.proxy.https_port` settings to no vail :-( – Rampy Jan 08 '15 at 04:33
  • Hmm apparently this might be a known problem with Splinter. I wish I could test it here instead of just sending you to a webpage, but see if any of the workaround solutions in [this thread](https://github.com/cobrateam/splinter/issues/120) help. The issue is also described [here](https://groups.google.com/forum/#!msg/splinter-users/G1oxcsqfcrA/I07j0YkOnB0J). There is a StackOverflow thread about urllib2 on Py2 [here](http://stackoverflow.com/questions/1481398/python-urllib2-https-and-proxy-ntlm-authentication); possibly the problem persists for urllib on Py3. – Roberto Jan 09 '15 at 13:18

1 Answers1

0

You can use selenium:

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

myProxy = "<you_proxy_ip>:<your_proxy_port>"

proxy = Proxy({
    'proxyType': ProxyType.MANUAL,
    'httpProxy': myProxy,
    'ftpProxy': myProxy,
    'sslProxy': myProxy,
    'noProxy': '' # set this value as desired
    })

driver = webdriver.Firefox(proxy=proxy)
driver.get("http://www.google.com")
Etienne Prothon
  • 982
  • 10
  • 30