Created
February 11, 2011 10:16
-
-
Save jackperry/822168 to your computer and use it in GitHub Desktop.
Found from Google. Saving here.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2, base64 | |
request = urllib2.Request('url') | |
base64string = base64.encodestring('%s:%s' % ('user', 'password'))[:-1] | |
request.add_header("Authorization", "Basic %s" % base64string) | |
htmlFile = urllib2.urlopen(request) | |
htmlData = htmlFile.read() | |
print htmlData | |
htmlFile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment