opener = urllib.request.build_opener()
opener.addheaders = [('Referer', referer), ('User-Agent', uagent), (
    'Accept-Encoding', 'gzip,deflate')]
usock = opener.open(url)
url = usock.geturl()
data = decode(usock)
usock.close()
return data
Url open encoding