#!/usr/bin/env python3 #coding=utf-8 import json import requests #from urllib import requests, parse,error # based url and required header #url = "http://sg-zabbix.upliveapp.com/zabbix/api_jsonrpc.php" class zabbixapi: '''获得token''' def __init__(self): self.url = 'http:// xxxxxxxx /zabbix/api_jsonrpc.php' self.headers = {'Content-Type': 'application/json'} auth = { "jsonrpc": "2.0", "method": "user.login", "params": { "user": " xxxxx ", ###验证 "password": " xxxxx " }, "id": 1, "auth": None, } response = requests.post(self.url, data=json.dumps(auth), headers=self.headers) self.authid = json