#coding = utf-8
from urllib.request import urlopen,Request
import gzip
import ssl
ssl._create_default_https_context = ssl._create_unverified_context()
path = "http://www.xbiquge.la/10/10489/4535761.html"
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36',
"Accept-Encoding": "gzip, deflate",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Accept-Language":"zh-CN,zh;q=0.9"
}
req = Request(url=path,headers=headers)
conn = urlopen(req)
if conn.code == 200:
#获取数据
data = conn.read()
print(type(data))
data = gzip.decompress(data).decode("utf-8")
print(data)
else:
print("网址有问题")