码迷,mamicode.com
首页 > 编程语言 > 详细

python获取请求头里面的cookie

时间:2020-04-18 16:06:05      阅读:342      评论:0      收藏:0      [点我收藏+]

标签:course   password   def   pytho   cookie   style   requests   get   数学   

 1 import requests
 2 class  ccedu(object):
 3     def get_cookie(self):
 4         #创建session对象
 5         session = requests.Session()
 6         url = "http://10.206.14.***:8080/ccsedu/a/login.do"
 7         payload = {args: None, usertype:2, username:********, password:********}
 8         #使用session发送post请求获取cookie
 9         session.post(url,data=payload)
10         print(session.cookies.get_dict())
11         return  session.cookies.get_dict()
12     def  addteacher(self,name,masterCourse,externalUnit,position):
13         url = "http://10.206.14.***:8080/ccsedu/a/js/jsgl/saveLecturer "
14         payload = {name: name, sex: 1, levels: 1, type: 2, masterCourse: masterCourse,
15                    externalUnit: externalUnit, position: position}
16         res = requests.post(url,data=payload,cookies=c.get_cookie())
17         print(res.json())
18 if __name__ == __main__:
19     c = ccedu()
20     c.addteacher("李睿",数学,未知机构,职务数学老师)

 

python获取请求头里面的cookie

标签:course   password   def   pytho   cookie   style   requests   get   数学   

原文地址:https://www.cnblogs.com/mudingxi/p/12725892.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!