1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| import json import re import requests from requests.auth import HTTPBasicAuth
userName="admin"
passWord="admin"
delTaskNodeURL="http://199.188.166.110:8080/MoiaControl/rest/RestService/delTaskNode"
taskNodesList=['a','b','c']
def request_post(url, param, user, pwd): try: headers = {'charset': 'utf-8'} result = requests.post(url, data=param, auth=HTTPBasicAuth(user,pwd)) text=result.content.decode() return text except Exception as e: print(e)
for item in taskNodesList: taskNodes={"taskNodes":"['%s']" % item} resInfo = request_post(delTaskNodeURL, taskNodes, userName, passWord) if not re.search(r"删除任务节点成功", resInfo): reason=json.loads(resInfo)["describe"] print("刪除任务节点[%s]失败: %s" % (item, reason)) else: reason = json.loads(resInfo)["describe"] print("刪除任务节点[%s]成功: %s" % (item, reason))
|