开发文档地址
python请求例子
import requests
import platform
import string
import hashlib
import random
#https://www.cnblogs.com/kangleweb/p/8358376.html
class KangLe:
def __init__(self):
URL = "http://你的ip:3312/api/index.php"
KEY = '后台安全码'
self.URL= URL
self.KEY = KEY
#计算MD5
def get_md5(self,a):
words = string.ascii_lowercase + string.ascii_uppercase + string.digits
chosen = random.sample(words, 5)
password = "".join(chosen)
A = a
KEY = self.KEY
p= password
num=A+KEY+p
m = hashlib.md5()
m.update(num.encode('utf-8'))
r=m.hexdigest()
#print(r)
return password ,r
#开通主机
def add_host(self,name,passwd):
my_api = KangLe()
re=my_api.get_md5("add_vh")
querystring = {
"c":"whm",
"a":"add_vh",
"r":re[0],
"s":re[1],
"name":name,
"passwd":passwd,
"init":"1",
"product_id":"1",
"json":"1"
}
payload = "-----011000010111000001101001--\r\n\r\n"
headers = {"content-type": "multipart/form-data; boundary=---011000010111000001101001"}
response = requests.request("GET", self.URL, data=payload, headers=headers, params=querystring)
print(response.text)
return response.text
if __name__ == '__main__':
my_api = KangLe()
re=my_api.add_host('name', 'passwd')
© 版权声明
THE END
暂无评论内容