M
Mark Ferguson
I've been trying to get a simple pycurl script working with an
authenticating proxy, here is the code (with changes to protect the
guilty!):
from pycurl import *
import StringIO
b = StringIO.StringIO()
c = Curl()
c.setopt(URL, "http://www.google.com/")
c.setopt(VERBOSE,1)
c.setopt(HTTPHEADER, ["User-Agent: Mozilla/5.001 (windows; U; NT4.0;
en-us) Gecko/25250101", "Agent: "])
c.setopt(PROXY, "dummyproxy")
c.setopt(PROXYPORT,80)
c.setopt(PROXYUSERPWD,"dummyuser:dummypasswd")
c.setopt(HTTPAUTH,8) #NTLM
c.setopt(WRITEFUNCTION, b.write)
c.setopt(FOLLOWLOCATION, 1)
c.setopt(MAXREDIRS, 5)
c.perform()
print b.getvalue()
And I get....
* About to connect() to dummyproxy:80
* Connected to dummyproxy (10.10.10.10) port 80
Authorization: NTLM TlRMTVNTUAABAAAAAgIAAAAAAAAgAAAAAAAAACAAAAA=
Host: www.google.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
User-Agent: Mozilla/5.001 (windows; U; NT4.0; en-us) Gecko/25250101
< HTTP/1.1 407 Proxy authentication required
< Proxy-Authenticate: NTLM
< Proxy-Connection: close
< Content-Length: 503
< Content-Type: text/html
* Connection #0 left intact
<html><head><title>Error 407</title>
<meta name="robots" content="noindex">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=iso-8859-1"></head>
<body>
<h2>HTTP Error 407</h2>
<p><strong>407 Proxy Authentication Required</strong></p>
<p>You must authenticate with a proxy server before this request can be
service
nd then try again.</p>
<p>Please contact the Web server's administrator if this problem
persists.</p>
</body></html>
* Closing connection #0
The username
assword combo are correct.
I'm stumped! suggestions gratefully accepted..
Mark.
authenticating proxy, here is the code (with changes to protect the
guilty!):
from pycurl import *
import StringIO
b = StringIO.StringIO()
c = Curl()
c.setopt(URL, "http://www.google.com/")
c.setopt(VERBOSE,1)
c.setopt(HTTPHEADER, ["User-Agent: Mozilla/5.001 (windows; U; NT4.0;
en-us) Gecko/25250101", "Agent: "])
c.setopt(PROXY, "dummyproxy")
c.setopt(PROXYPORT,80)
c.setopt(PROXYUSERPWD,"dummyuser:dummypasswd")
c.setopt(HTTPAUTH,8) #NTLM
c.setopt(WRITEFUNCTION, b.write)
c.setopt(FOLLOWLOCATION, 1)
c.setopt(MAXREDIRS, 5)
c.perform()
print b.getvalue()
And I get....
* About to connect() to dummyproxy:80
* Connected to dummyproxy (10.10.10.10) port 80
Proxy-authorization: Basic ZHVtbXl1c2VyOmR1bW15cGFzc3dk> GET http://www.google.com/ HTTP/1.1
Authorization: NTLM TlRMTVNTUAABAAAAAgIAAAAAAAAgAAAAAAAAACAAAAA=
Host: www.google.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
User-Agent: Mozilla/5.001 (windows; U; NT4.0; en-us) Gecko/25250101
< HTTP/1.1 407 Proxy authentication required
< Proxy-Authenticate: NTLM
< Proxy-Connection: close
< Content-Length: 503
< Content-Type: text/html
* Connection #0 left intact
<html><head><title>Error 407</title>
<meta name="robots" content="noindex">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=iso-8859-1"></head>
<body>
<h2>HTTP Error 407</h2>
<p><strong>407 Proxy Authentication Required</strong></p>
<p>You must authenticate with a proxy server before this request can be
service
nd then try again.</p>
<p>Please contact the Web server's administrator if this problem
persists.</p>
</body></html>
* Closing connection #0
The username
I'm stumped! suggestions gratefully accepted..
Mark.