Skip to content

Instantly share code, notes, and snippets.

@alexnavis
Last active July 11, 2018 13:17
Show Gist options
  • Save alexnavis/7b3a853778d8334c233eba3b46080992 to your computer and use it in GitHub Desktop.
Save alexnavis/7b3a853778d8334c233eba3b46080992 to your computer and use it in GitHub Desktop.
Python HTTP/HTTPS code to login
import urllib, urllib2, cookielib
URL = 'http://dummyurl.com'
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
login_data = urllib.urlencode({ "password":"12345678", "email":"xyz@gmail.com" })
resp = opener.open(URL, login_data)
print resp.headers
print resp.read()
from pprint import pprint
pprint (vars(resp))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment