在python3.3里面,用urllib.request代替urllib2
-
import urllib.request
-
-
url =
"http://www.baidu.com"
-
response1 = urllib.request.urlopen(url)
-
#打印请求的状态码
-
print(response1.getcode())
-
#打印请求的网页内容的长度
-
print(len(response1.read()))