Skip to content

Instantly share code, notes, and snippets.

@nicolasmendoza
Created February 6, 2015 05:16
Show Gist options
  • Save nicolasmendoza/f0cc678137dcb2064b9b to your computer and use it in GitHub Desktop.
Save nicolasmendoza/f0cc678137dcb2064b9b to your computer and use it in GitHub Desktop.
request with urlib2
import urllib2
from base64 import b64encode
request = urllib2.Request('https://api.xxxx.com/user')
request.add_header('Authorization', 'Basic ' + b64encode('user' + ':' + 'pass'))
r = urllib2.urlopen(request)
print r.getcode()
print r.headers["content-type"]
print r.headers["X-RateLimit-Limit"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment