Skip to content

Instantly share code, notes, and snippets.

@EdwardIII
Created September 7, 2012 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EdwardIII/3664469 to your computer and use it in GitHub Desktop.
Save EdwardIII/3664469 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import urllib2
url = 'https://myserver.org:2087/json-api/listaccts'
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password('cPanel', url, 'myuser', 'mysecret')
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
result = urllib2.urlopen(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment