secret
Created

print page info

  • Download Gist
print-page-info.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14
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))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.