from twisted.web import client
from twisted.internet import reactor
import base64
import sys
def printPage(data):
print data
reactor.stop()
def printError(failure):
print >> sys.stderr, "Error:", failure.getErrorMessage()
reactor.stop()
if len(sys.argv) == 4:
url = sys.argv[1]
username = sys.argv[2]
password = sys.argv[3]
basicAuth = base64.encodestring('%s:%s' % (username, password))
authHeader = "Basic " + basicAuth.strip()
client.getPage(url, headers={"Authorization":
authHeader}).addCallback(printPage).addErrback(printError)
reactor.run()
else:
print 'Usage: get_web_page.py <URL>'
If I run this against a password protected HTTP(S) site from a host
that has direct access to the Internet it works fine. I now have to
move it behind a proxy that requires authentication. The Twisted
documentation did not make it clear (to me) how to add proxy
authentication and I cannot find an example on the Internet.
I've tried adding an additional Proxy-Authentication header to the
call, but that doesn't help Any ideas would be greatly appreciated.
Command line args: http://feedparser.org/docs/examples/basic_auth.xml
test basic
--
http://mail.python.org/mailman/listinfo/python-list