views:

654

answers:

3

I'm trying to fetch some urls via urllib and mechanize through my proxy.

With mechanize I try the following:

from mechanize import Browser
import re

br = Browser()
br.set_proxies({"http": "MYUSERNAME:*******@itmalsproxy.italy.local:8080"})
br.open("http://www.example.com/")

I get the following error:

httperror_seek_wrapper: HTTP Error 407: Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied.

As the proxy, the username and the password are correct, what could be the problem?

A: 

Maybe the proxy is using NTLM authentication?

If that is the case, you can try using the NTLM Authorization Proxy Server (see also this answer).

codeape
thanks for the suggestion, i tried with http://code.google.com/p/python-ntlm/ and still get the very same error
pistacchio
I do not believe that python-ntlm supports NTML proxies (only direct HTTP connections). Did you try NTLM authorization proxy server?
codeape
i tried, it is not a ntlm proxy
pistacchio
A: 

you might get more info from the response headers

print br.response().info()

mykhal
A: 

When your web browser uses proxy server to surf the Web from within your local network your may be required to authenticate youself to use proxy. Google ntlmaps.

hollerith