Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > getting debug from urllib2

Reply
Thread Tools

getting debug from urllib2

 
 
Ben Edwards
Guest
Posts: n/a
 
      07-31-2006
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?
Ben

* Code *

import urllib, urllib2, httplib

url = 'http://www.mozillazine.org/atom.xml'
httplib.HTTPConnection.debuglevel = 1

print "urllib"

data = urllib.urlopen(url);

print "urllib2"

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

print "End\n"

* Output *

urllib
connect: (www.mozillazine.org, 80)
send: 'GET /atom.xml HTTP/1.0\r\nHost: www.mozillazine.org\r
\nUser-agent: Python-urllib/1.16\r\n\r\n'
reply: 'HTTP/1.0 200 OK\r\n'
header: Date: Mon, 31 Jul 2006 13:43:11 GMT
header: Server: Apache/2.0.55 (Gentoo) PHP/4.4.0-pl1-gentoo
header: Last-Modified: Thu, 27 Jul 2006 18:05:52 GMT
header: ETag: "20a1b4-6bcf-be12000"
header: Accept-Ranges: bytes
header: Content-Length: 27599
header: Content-Type: application/xml
header: Age: 5
header: X-Cache: HIT from mz5.mz.osuosl.org
header: X-Cache-Lookup: HIT from mz5.mz.osuosl.org:80
header: Connection: close
urllib2
End



 
Reply With Quote
 
 
 
 
Peter Otten
Guest
Posts: n/a
 
      07-31-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(debugleve l=1))
feeddata = opener.open(request).read()

Peter
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting all HTTP headers from urllib2 Request? cgoldberg Python 5 03-03-2009 06:12 PM
Config Mgr Debug/Release and Web.config Compilation debug=true RonL ASP .Net 0 04-08-2006 03:50 PM
urlerror, urllib2: "no address" ... why or debug tips? joemynz@gmail.com Python 1 03-10-2006 11:18 AM
Problem with: urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) Josef Cihal Python 0 09-05-2005 11:26 AM
Debug (DLL MFC) -> Debug (Static MFC) ringos75 C++ 0 04-14-2005 01:50 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57