import os import io import sys import ssl import urllib.request #from importlib import reload # 第一个爬虫练习 """ url= "http://www.baidu.com" data = urllib.request.urlopen(url).read()# #data = data.decode('UTF-8') print (data) """ sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') url = "https://www.douban.com" request = urllib.request.Request(url) ssl._create_default_https_context = ssl._create_unverified_context responseurl = urllib.request.urlopen(request) data = responseurl.read() data = data.decode('utf-8') print(data) print(type(responseurl)) print(responseurl.geturl()) print(responseurl.info()) print(responseurl.getcode())