-
-
Save zed/fa9e9efc83a53df02e29 to your computer and use it in GitHub Desktop.
print page info
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
try: | |
from urllib2 import urlopen | |
except ImportError: | |
from urllib.request import urlopen | |
url, encoding = 'http://stackoverflow.com/q/9445627/', 'utf-8' | |
response = urlopen(url) | |
print(response.info()) | |
page_bytes = response.read() | |
print("Raw bytes:") | |
print(repr(page_bytes[:40])) | |
print("Decoded:") | |
print(page_bytes.decode(encoding)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment