[Tutor] Requesting restricted URL (further authentication requested)

Vince Spicer vince at vinces.ca
Tue Oct 19 22:04:32 CEST 2010


On Tue, Oct 19, 2010 at 1:56 PM, Tim Johnson <tim at johnsons-web.com> wrote:

> I've written the following function which successfully gets an
> authenticated URL:
> def getRestrictedURL(authName,URL,log,pswd):
>        auth_handler = urllib2.HTTPBasicAuthHandler()
>        auth_handler.add_password(authName, URL,log,pswd)
>        opener = urllib2.build_opener(auth_handler)
>        urllib2.install_opener(opener)
>        return opener.open(URL).read()
> # But, alas, any links in content 'beneath' the URL
> # require additional authentication.
> Any way around this?
> Thanks
> --
> Tim
> tim at johnsons-web.com or akwebsoft.com
> http://www.akwebsoft.com
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

Tim,

Unless you are tied to the standard library I would recommend looking at

httplib2  http://code.google.com/p/httplib2/

This handles your authentication and connection much better then the
standard urllib.

-- 
Vince Spicer

-- 
Sent from Ubuntu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101019/dd356d22/attachment.html>


More information about the Tutor mailing list