unittest(22)- p2p项目实战(2)-http_request
2021-04-24 23:26
标签:nbsp erro exception bsp res format err unittest cookie unittest(22)- p2p项目实战(2)-http_request 标签:nbsp erro exception bsp res format err unittest cookie 原文地址:https://www.cnblogs.com/come202011/p/12232168.html# 2. http_request.py
import requests
from learn_logging_5.write_log_class import MyLog
my_logger = MyLog()
class HttpRequest:
def http_request(self, url, method, data=None, cookie=None):
try:
if method.upper() == "GET":
res = requests.get(url, data, cookies=cookie)
elif method.upper() == "POST":
res = requests.post(url, data, cookies=cookie)
else:
my_logger.info("请输入正确的参数")
except Exception as e:
my_logger.error("请求报错了:{}".format(e))
raise e
return res
上一篇:CSS的语法规范
下一篇:网页如何进行性能测试工具
文章标题:unittest(22)- p2p项目实战(2)-http_request
文章链接:http://soscw.com/index.php/essay/79147.html