import urllib.request def gethtml(url='http://www.baidu.com')
http_handler = urllib.request.HTTPHandler(debuglevel=0) http_redirect_handler=urllib.request.HTTPRedirectHandler() opener = urllib.request.build_opener(http_redirect_handler,http_handler) opener.addheaders=[ ('pragma','no-cache'), ('Content-Type','/') ] request=urllib.request.Request(url) response=opener.open(request) print(response.read().decode('utf-8'))