Skip to content

Instantly share code, notes, and snippets.

@iiska
Created May 7, 2012 12:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save iiska/2627553 to your computer and use it in GitHub Desktop.
Save iiska/2627553 to your computer and use it in GitHub Desktop.
Using urllib2 and cookielib to print cookies from GET request
import urllib2
import cookielib
cookie_jar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie_jar))
urllib2.install_opener(opener)
request = urllib2.Request('http://www.google.com')
urllib2.urlopen(request)
for cookie in cookie_jar:
print cookie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment