zoukankan      html  css  js  c++  java
  • python获取请求头里面的cookie

     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("李睿",'数学','未知机构','职务数学老师')
  • 相关阅读:
    Django部署到服务器
    springboot使用Redis缓存
    ubuntu下pip更换国内源
    ubuntu环境变量文件
    python open找不到路径
    centos 8 安装nginx
    centos8 mysql8的远程访问
    centos 8 安装mysql-server 8
    今日收获
    今日收获
  • 原文地址:https://www.cnblogs.com/mudingxi/p/12725892.html
Copyright © 2011-2022 走看看