Skip to content

Instantly share code, notes, and snippets.

@flyudvik
Created April 25, 2018 09:59
Show Gist options
  • Save flyudvik/5abe5f1ceca77c459a88f042b19e4e2a to your computer and use it in GitHub Desktop.
Save flyudvik/5abe5f1ceca77c459a88f042b19e4e2a to your computer and use it in GitHub Desktop.
Pickle and unpickle session. Good to save the request sessions for cli app without making authentication
import requests, requests.utils, pickle
session = requests.session()
# Make some calls
# save session
with open('somefile', 'w') as f:
pickle.dump(session, f)
# sessiong restore
with open('somefile') as f:
session = pickle.load(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment