# -*- coding: utf-8 -*-
import requests
import json
class web_requests(object):
def __init__(self):
pass
def Interface(self,Interface_path,**My_data):
url = "http://testdj.XXXXXX.com:8378/%s" %(Interface_path) # 测试的接口url
headers = {"Host": "testdj.XXXXXX.com:8378",
"Accept": "application/json, text/plain, */*",
"Referer": "http://testdj.XXXXXX.com:8280/",
"Accept-Language": "zh-CN,zh;q=0.8",
"Origin": "http://testdj.XXXXXX.com:8280",
"Accept-Encoding": "gzip, deflate",
"Accept": "application/json, text/plain, */*",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36"} #消息头
data = {"beginDate": "2018-01-01", "endDate": "2018-04-01"} # 接口传送的参数
r = requests.get(url=url, json=data, headers=headers) # 发送请求
# return r.json
print (r.text) # 获取响应报文
print (r.status_code)
a = web_requests()
a.Interface('monitor/sxsb-sxzl',beginDate="2018-01-01", endDate="2018-04-01")