Browser instance on a network with proxy
Hi.
I'm trying to run Splinter in a Windows 7 machine, in a local network that needs a proxy.
When a new instance of the Browser() is created in the python shell, a firefox window pop-ups with the profile different than the one that I use. So, this new instance and profile don't have none of the configs for proxy.
This is the message generated by the "browser = Browser()" code:
Traceback (most recent call last):
File "C:\Users\cassio.nandi\Desktop\splinter\exemplo.py", line 3, in \nNa tentativa de recuperar a URL:\nhttp://127.0.0.1:51372/hub/session\n \nO seguinte erro foi encontrado:\n \nO controle de acessos impediu sua requisição.\nCaso você não concorde com isso, por favor, \ncontate seu provedor de serviços, ou o administrador de sistemas.\nERRO
\nA URL solicitada não pode ser recuperada
\n
\n\n
\n
\n
\n\nGenerated Tue, 08 Nov 2011 18:27:08 GMT by proxy (squid/2.6.STABLE21)\n\n\n'
Marked as a bug. Thanks for reporting.
How do you use this proxy? Is a configuration on SO or a plugin in firefox?
On a pt-br firefox
Opções -> Avançado -> Rede -> Configurar Conexão.
Configuração manual de proxy
Usar este proxy para todos os protocolos
this configuration works on any instances of firefox?
It is not present in the intance opened by the splinter, I supose because the temporary profile created on-the-fly.
try open it with your firefox profile
I configured the IE network settings with the proxy and to ignore 127.0.0.1. This makes everything work fine, but I need to say that my profile was loaded but ignored and overided by the system network config
The problem related to httplib.
More details: http://groups.google.com/group/splinter-users/msg/1d9c0e89d1e34e23
Howdy!
This question, like Francisco said, is related to httplib, once it doesn't look for proxy configs in your system. It could be solved with urllib2 easily, I haven't done this yet because this would cause an interface change in splinter, we would have to remove the status_code property from the webdrivers, which was implemented solving issue 35. The reason why we can't keep it, is that urllib2 does not give us access to http status code when we make a request, only when it raises an HTTPError.
The status_code support was not the goal of issue 35, it's a gain.
I'm bringing this up because the status_code is part of the webdriver's api, and remove it will break people who are using it.
If the problem is that urllib2 doesn't provide the status_code of every page, we can move straight to urllib3, as it provides the status_code of every request.
What do you think about it?
Howdy!
Maybe it's a good idea, but I read (not carefully :P) the urlilb3 docs, and I didn't found any way to configure a proxy with authentication, if it not support this feature, we're gonna be in the same place we are right now, with httplib.
Do you have a link showing how to do that with urllib3? Just in case that I haven't seen this (what probably happened).
I heard something about httplib2 giving support to proxy.
Looks like httplib2 only supports SOCKS proxies without authentication. I still think we should use urllib3, so we can fetch all those status_code and will have increased performance in some cases. In my opinion, there's no networking library for python with support to authenticated proxies.
Hey!
I haven't seen httplib2 yet.. so I can't say anything about it right now.
This is our requirements:
- support proxy with authentication
- have a status_code attribute
@douglascamata do you have a link that shows urllib3 proxy authentication sopport? I was not able to find it myself..
@flaviamissi no, and I can't find any python lib that can do that.
Well, don't know if you have found any resources related to 'urllib and proxy support', but this might help:
- http://stackoverflow.com/questions/1481398/python-urllib2-https-and-proxy-ntlm-authentication
- http://code.activestate.com/recipes/301740-simplest-useful-https-with-basic-proxy-authenticat/
- http://www.daniweb.com/software-development/python/threads/323587
and the best one (tooked from http://bytes.com/topic/python/answers/22918-proxy-authentication-using-urllib2):
import urllib2
proxy_info = {
'user' : 'username',
'pass' : 'password',
'host' : "proxy.name.com",
'port' : 80 # or 8080 or whatever
}
# build a new opener that uses a proxy requiring authorization
proxy_support = urllib2.ProxyHandler({"http" : \
"http://%(user)s:%(pass)s@%(host)s:%(port)d" % proxy_info})
opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)
# install it
urllib2.install_opener(opener)
# use it
f = urllib2.urlopen('http://www.python.org/')
print f.headers
print f.read()
Big thanks @gabriellima, I'll try to make it work with urllib3.
@gabriellima Yes, as I said before, I know urllib2 has this support, they have an example just like yours in the docs, what urllib2 doesn't have is a status_code, that we also need.
But thank's for the sample.
Now I got what you mean. Hope you find this 'status_code' attribute helper :)
Good luck :)
Ahh, doesn't it come with the response of trying to access the page? I don't know urllib fairly well.
I'm removing the "bug" label. We were not expecting to support this feature :)