爬虫3 requests基础
import requests # get实例 # res = requests.get('http://httpbin.org/get') # # res.encoding='utf-8' # print(res.encoding) #编码格式 # print(res.text)#获取文本 ##################### #post实例 # info = { # 'username':'QiuGeiWa', # 'password':'asdas' # } # res = requests.post('http://httpbin.org/post',data=info) # # print(res.text) # print(res.url) ###################### #?后面参数实例 info = { 'username':'QiuGeiWa', 'password':'asdas' } params ={ 'ha':'asd', 'b' : 'sadas' } headers = { 'a': "sadas" } co = { 'session-id':'1112' } res = requests.post('http://httpbin.org/post', data=info, params = params, headers=headers, cookies = co ) print(res.url) # print(res.text) print(res.request.headers) print(res.cookies)