Skip to content

Instantly share code, notes, and snippets.

@kudarisenmon
Created January 29, 2020 12:55
Show Gist options
  • Select an option

  • Save kudarisenmon/3db58c46f54321e043333ff757b0f497 to your computer and use it in GitHub Desktop.

Select an option

Save kudarisenmon/3db58c46f54321e043333ff757b0f497 to your computer and use it in GitHub Desktop.
print cookies from GET request on python3
# -*- coding: utf-8 -*-
from urllib.request import build_opener, HTTPCookieProcessor
from urllib.parse import urlencode
from http.cookiejar import CookieJar
import pprint
cookie_jar = CookieJar()
opener = build_opener(HTTPCookieProcessor(cookie_jar))
res = opener.open('https://www.google.com')
#pprint.pprint(res.getheaders())
res.close()
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