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

 

posted @ 2017-04-12 22:42  layfork  阅读(116)  评论(0编辑  收藏  举报