Skip to content

Instantly share code, notes, and snippets.

@carlcarl
Created October 28, 2012 11:13
Show Gist options
  • Save carlcarl/3968352 to your computer and use it in GitHub Desktop.
Save carlcarl/3968352 to your computer and use it in GitHub Desktop.
python requests with session
from requests import session
payload = {
'action': 'login',
'username': USERNAME,
'password': PASSWORD
}
with session() as c:
c.post('http://example.com/login.php', data=payload)
request = c.get('http://example.com/protected_page.php')
print request.headers
print request.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment