#coding=utf-8 """ =========================== Author:多测师_王sir Time:2020/5/20 17:24 Wechat:15367499889 Company:上海多测师信息有限公司 =========================== """ import requests class SendRequest(object): """cookie+session鉴权的请求类封装""" def __init__(self): #通过在创建类的时候就创建session对象 self.session = requests.session() def send(self, url, method, headers=None, params=None, data=None, json=None, files=None): method = method.lower() if method == "get": response = self.session.get(url=url, params=params, headers=headers) elif method == "post": response = self.session.post(url=url, json=json, data=data, files=files, headers=headers) return response