Posted By

manatlan on 09/12/09


Tagged

python web


Versions (?)

request web with cookies handling


 / Published in: Python
 

  1. import cookielib, urllib, urllib2
  2.  
  3. # install an urlopener which handle cookies
  4. cookiejar = cookielib.CookieJar()
  5. opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
  6. urllib2.install_opener(opener)
  7.  
  8. request = urllib2.Request("http://google.fr", None, {})
  9. r=urllib2.urlopen(request)
  10.  
  11. for i in cookiejar:
  12. print i

Report this snippet  

You need to login to post a comment.