#!/usr/bin/env python
# example p4
import urllib.request,  ssl

url1 = 'https://google.com'
resp = urllib.request.urlopen(url1)

contents_bytes = resp.read()

for decoder in \
    ['utf-8', 'ascii', 'latin-1', 'ebcdic']:
    try:
        contents = contents_bytes.decode(decoder)
        print(decoder, 'succeeded')
        break   # out of the for-loop
    except:
        print(decoder, 'does not work')

print(len(contents), type(contents))