从第二种方法就开始报错??求大神指导一下!
import urllib.request;
import http.cookiejar;
url = "http://www.baidu.com";
print("there are three methods to get url.")
print("first");
response1 = urllib.request.urlopen(url);
print(response1.getcode());
# 200 表示获取url地址成功
print(len(response1.read()));# 打印长度
#print("多行注释");
print("second");
request = urllib.request(url);
request.add_header("user_agent" , "Mozilla/5.0");
response2 = urllib.request.urlopen(request);
print(response2.getcode());
print(len(response2.read()));
# print("单行注释");
print("third");
'''
cj = http.cookiejar();
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj));
urllib.request.install_opener(opener);
response3 = urllib.request.urlopen(url);
print(response3.getcode());
print(cj);
print(len(response3.read()));
'''