getting debug from urllib2

Peter Otten __peter__ at web.de
Mon Jul 31 14:05:16 EDT 2006


Ben Edwards wrote:

> Have been experimenting with HTTP stuff in python 2.4 and am having a
> problem getting debug info. If I use utllib.utlopen I get debug but if I
> user utllib2 I do not.  Below is the probram and the output I am
> getting.
> 
> Any insight?

Use the source :-) 

urllib2.build_opener() accepts prebuilt handlers:

import urllib2

url = 'http://www.mozillazine.org/atom.xml'

request = urllib2.Request(url)
opener = urllib2.build_opener(urllib2.HTTPHandler(debuglevel=1))
feeddata = opener.open(request).read()

Peter



More information about the Python-list mailing list