473,387 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

getting debug from urllib2

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

Jul 31 '06 #1
1 11113
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
Jul 31 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: O. Koch | last post by:
Until now, i know that ftplib doesn't support proxies and that i have to use urllib2. But i don't know how to use the urllib2 correct. I found some examples, but i don't understand them. Is...
4
by: bmiras | last post by:
I've got a problem using urllib2 to get a web page. I'm going through a proxy using user/password authentification and i'm trying to get a page asking for a HTTP authentification. And I'm using...
2
by: John F Dutcher | last post by:
Can anyone comment on why the code shown in the Python error is in some way incorrect...or is there a problem with Python on my hoster's site ?? The highlites don't seem to show here...but line...
1
by: Ray Slakinski | last post by:
Hello, I have defined a function to set an opener for urllib2, this opener defines any proxy and http authentication that is required. If the proxy has authencation itself and requests an...
1
by: joemynz | last post by:
Help please with a URLError. Invoking a url that works in Firefox and IE results in a "urlerror 7, no address ..." in python. I need to debug why. Traceback is below. There's a redirect when the...
5
by: blair.bethwaite | last post by:
Hi Folks, I'm thinking about writing a script that can be run over a whole site and produce a report about broken links etc... I've been playing with the urllib2 and httplib modules as a...
0
by: Baptiste Lepilleur | last post by:
I activated httplib debug, and when trace are printed, a UnicodeError exception is thrown. I have already set sys.stdout to use utf-8 encoding (this removed the exception when *I* was printing...
1
by: Alessandro Fachin | last post by:
I write this simply code that should give me the access to private page with htaccess using a proxy, i don't known because it's wrong... import urllib,urllib2 #input url...
1
by: iBlaine | last post by:
I'm hoping someone here can answer my problem - I'm getting a 500 error when I run this code. What it should do is setup cookies, log in, then post a file to a form. The problem is it throws an...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.