Hi Martin,

print 'status:', response.status
> print 'reason:', response.reason
> print 'document:', response.read()
>

This is definitly what i was looking for and did not know in which module to
look.
Thank you so much for the code illusration.

Monika.


2008/4/20, Martin Walsh <[EMAIL PROTECTED]>:
>
> Monika Jisswel wrote:
> > Hi,
> >
> > can i stop urllib2.urlopen() from  following redirects automatically ?
>
>
> It doesn't answer your question directly, but if you care more about the
> initial request/response than the content at the other end of a redirect
> -- you can use httplib. It might look something like this:
>
> """
> import urlparse
> import httplib
>
> url = urlparse.urlsplit('http://google.com/search?q=python')
> host = url[1]
> path = urlparse.urlunsplit(('', '')+url[2:])
>
> con = httplib.HTTPConnection(host)
> con.request('GET', path)
> response = con.getresponse()
>
> print 'status:', response.status
> print 'reason:', response.reason
> print 'document:', response.read()
> """
>
> You lose many advantages of the higher-level urllib2, as it does much of
> the mundane work for you -- parsing urls, choosing http or https
> transparently, etc -- but I think httplib is still appropriate if your
> needs are simple.
>
> More information here:
> http://docs.python.org/lib/module-httplib.html
>
> HTH,
> Marty
>
>
> > thanks in advance
> >
> > Monika Jissvel
> >
>
>
>
> _______________________________________________
> Tutor maillist  -  [email protected]
> http://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to