Skip to content

Instantly share code, notes, and snippets.

@gaotongfei
Forked from iiska/print_cookies.py
Created November 21, 2015 03:44
Show Gist options
  • Save gaotongfei/5415382b696d75247c0b to your computer and use it in GitHub Desktop.
Save gaotongfei/5415382b696d75247c0b 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