<python模块>Requests

时间:Dec. 20, 2019 分类:

目录:

常用get和post操作

headers = {
        "Content-Type": "application/json",
        "Authorization": "Token 61c8af7afd24853995cf679f5f84258d87204aa1",
}

url = "http://192.168.21.142:22222/pipline/operation/"
response = requests.get(url=url, headers=headers)
print(response.status_code, response.text)

url = "http://192.168.21.142:22222/pipline/operation/"
j = {
  "name": "test4",
  "operation_type": 1,
  "command": "ping 192.168.21.28",
  "rely_on_operation": [1, 2]
}
response = requests.post(url=url,json=j, headers=headers)
print(response.status_code, response.text)

参考文档