青龙面板已经玩儿了一段时间了,效果不错,白嫖感觉非常好,搭建教程请看:京东白嫖——青龙面板。由于各种公开的挂机代码经常被封,所以一般搭建好了就自己一个人用,非常浪费资源。有大佬自己抓包了青龙面板的请求接口,并封装成了Python的api,感兴趣的可以自己试试。
复制
#更新到青龙面板 import requests import json import re import time import configparser class Update(): def __init__(self,ck=None,phone=None): #青龙面板地址、账号密码 conf = configparser.ConfigParser() conf.read("./config.ini", encoding='UTF-8') self.host = conf["ql"].get('host') self.client_id = conf["ql"].get('client_id') self.client_secret = conf["ql"].get('client_secret') self.ck = ck self.token = self.get_token() self.phone = phone def get_token(self): url = self.host + "open/auth/token?client_id={}&client_secret={}".format(self.client_id,self.client_secret) response = requests.request("GET", url).json() print("获取青龙面板的token:",response) return response["data"]["token"] # 比对ck进行更新,如果未启用,进行启用 def match_ck(self): pt_pin = str(re.findall(r"pt_pin=(.+?);", self.ck)[0]) print("手机号码{}的pt_pin:".format(self.phone),pt_pin) cklist = self.get_all_ck() for i in cklist: if pt_pin in str(i["value"]): print("匹配成功,匹配到当前变量:",i) id = i["_id"] remark = i["remarks"] print("-------------------") print("开始更新{}的ck".format(remark)) self.update_ck(remark,id) if i["status"] == 1: print("{}启用成功".format(remark)) self.start_ck(id) return self.add_ck() print("新增{}手机号码的ck".format(self.phone)) return # 获取所有的变量 def get_all_ck(self): t = int(round(time.time() * 1000)) url = self.host + "open/envs?searchValue=&t="+str(t) payload = "" headers = { 'Authorization': 'Bearer '+self.token } response = requests.request("GET", url, headers=headers, data=payload).json() print("获取青龙面板所有的变量进行比对") return response["data"] # 更新变量 def update_ck(self,remark=None,id=None): t = int(round(time.time() * 1000)) url = self.host+"open/envs?t="+str(t) payload = json.dumps({ "name": "JD_COOKIE", "value": self.ck, "remarks": remark, "_id": id }) headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer '+self.token } print("更新变量") response = requests.request("PUT", url, headers=headers, data=payload) return def add_ck(self): t = int(round(time.time() * 1000)) url = self.host+"open/envs?t="+str(t) payload = json.dumps([ { "value": self.ck, "name": "JD_COOKIE", "remarks": self.phone } ]) headers = { 'Authorization': 'Bearer '+self.token, 'Content-Type': 'application/json' } print("添加变量") response = requests.request("POST", url, headers=headers, data=payload) return def start_ck(self,id): t = int(round(time.time() * 1000)) url = self.host+"open/envs/enable?t="+str(t) print(id) list=[] list.append(id) payload = json.dumps( list ) headers = { 'Authorization': 'Bearer '+self.token, 'Content-Type': 'application/json' } print("启用ck:",payload) response = requests.request("PUT", url, headers=headers, data=payload) return
方法如下:
- get_token():获取token;
- match_ck():比对ck进行更新,如果未启用,进行启用;
- get_all_ck():获取青龙面板的所有变量(ck);
- update_ck():更新青龙面板的单个变量(ck);
- add_ck():添加变量(ck);
- start_ck():启用变量(ck);
简单使用:
复制
if __name__ == '__main__': ck = 'pt_key=33JiC5lOADBAJIqAX8UDhNHkh_qypfyAyQkqWu5ADdZgHkudbNtdlSkBEOIMxO73oT_npf__Hvc;pt_pin=jd_67r828540e7yd;' 如果知道手机号码,可以传phone作为标记,不然账号太多会比较乱 Update(ck=ck).match_ck()
转自吾爱破解,代码未测试,应该是没问题的。另外,谁知道官方的openapi文档在哪里?找不到!
评论 (3)