标签:
通过Python调用iTop的Webservice接口:
#!/usr/bin/env python #coding: utf-8 import requests import json itopurl = "https://itsm.google.cn/webservices/rest.php" # opr = json.dumps( # {‘operation‘:‘list_operations‘} # ) opr = json.dumps( { ‘operation‘:‘core/get‘, ‘class‘: ‘FunctionalCI‘, ‘key‘:"SELECT FunctionalCI", ‘output_fields‘ : ‘name , contacts_list‘} ) payload={ "version":"1.0", "auth_user":"admin", "auth_pwd":"your_pwd", "json_data":opr } r = requests.post(url=itopurl, data=payload) dict_r = json.loads(r.content) fp = open("server.csv","w+") for item in dict_r[‘objects‘]: if len(dict_r[‘objects‘][item][‘fields‘][‘contacts_list‘]) == 0: # print dict_r[‘objects‘][item][‘fields‘][‘name‘] fp.write(dict_r[‘objects‘][item][‘fields‘][‘name‘] + "\n") fp.close()
https://sourceforge.net/p/itop/discussion/922361/thread/0c0ad12f/
https://wiki.openitop.org/doku.php?id=advancedtopics:rest_json
http://www.07net01.com/program/2016/02/1304701.html
标签:
原文地址:http://www.cnblogs.com/IvanChen/p/5526739.html