requests库比urllib跟家方便操作Cookie、登录验证、代理设置等;
例如:
1 #requests库,get请求 2 import requests 3 #请求数据 4 data={ 5 \'name\':"JONES", 6 \'age\':34 7 } 8 r = requests. get(\'\',params=data) 9 print(type(r)) 10 print(r.status_code) 11 print (type(r.text)) 12 print(r. text) 13 print(r.cookies) 14 print(r.json())#获取一个json对象 15 print(type(r.json()))