python网络

try:
    import urllib.request as urllib2
except ImportError:
    import urllib2


response = urllib2.urlopen("http://www.baidu.com")
print(response.getcode())

response = urllib2.urlopen('http://www.cnblogs.com/txw1958/archive/2012/03/12/2392067.html')
html = response.read()
print(html.decode('utf-8')) //16进制转utf-8
原文地址:https://www.cnblogs.com/norm/p/6701813.html