权朗网络API3.0

权朗网络API3.0


Python

<pre><code class="language-python">import requests,time,random,hashlib,threading center_id = 1111; #开发者id api_password = &amp;#039;123123&amp;#039;; #api密码 software = &amp;#039;test&amp;#039;; #软件名称 card = &amp;#039;testcard&amp;#039;; #卡密 local_storage = {} def get_net_timestamp(platform=&amp;#039;taobao&amp;#039;): if platform == &amp;#039;taobao&amp;#039;: try: res = requests.get(&amp;#039;https://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp&amp;#039;, timeout=5) obj = res.json() except Exception as e: obj = None if not obj or &amp;#039;data&amp;#039; not in obj: print(&amp;#039;获取淘宝时间戳失败,开始获取拼多多时间戳&amp;#039;) return get_net_timestamp(&amp;#039;pdd&amp;#039;) else: print(&amp;#039;获取淘宝时间戳成功&amp;#039;) return int(str(obj[&amp;#039;data&amp;#039;][&amp;#039;t&amp;#039;])[:10]) elif platform == &amp;#039;pdd&amp;#039;: try: res = requests.get(&amp;#039;https://api.pinduoduo.com/api/server/_stm&amp;#039;, timeout=5) obj = res.json() except Exception as e: obj = None if not obj or &amp;#039;server_time&amp;#039; not in obj: print(&amp;#039;获取拼多多时间戳失败,开始获取世界时间戳&amp;#039;) return get_net_timestamp(&amp;#039;world&amp;#039;) else: print(&amp;#039;获取拼多多时间戳成功&amp;#039;) return int(str(obj[&amp;#039;server_time&amp;#039;])[:10]) elif platform == &amp;#039;world&amp;#039;: try: res = requests.get(&amp;#039;https://worldtimeapi.org/api/timezone/Asia/Shanghai&amp;#039;, timeout=5) obj = res.json() except Exception as e: obj = None if not obj or &amp;#039;unixtime&amp;#039; not in obj: print(&amp;#039;获取世界时间戳失败,开始获取本地时间戳&amp;#039;) return get_net_timestamp(&amp;#039;local&amp;#039;) else: print(&amp;#039;获取世界时间戳成功&amp;#039;) return int(obj[&amp;#039;unixtime&amp;#039;]) else: print(&amp;#039;获取本地时间戳&amp;#039;) return int(time.time()) def hex_md5(s): return hashlib.md5(s.encode(&amp;#039;utf-8&amp;#039;)).hexdigest() def ql_request(api, param): api_list = [ &amp;#039;https://napi.2cccc.cc/&amp;#039;, &amp;#039;http://api2.2cccc.cc/&amp;#039;, &amp;#039;http://api3.2cccc.cc/&amp;#039; ] connect_server_times = 0 server_return_json = &amp;#039;&amp;#039; # 添加全局参数 param[&amp;#039;center_id&amp;#039;] = center_id param[&amp;#039;software&amp;#039;] = software while True: if connect_server_times &amp;gt; 0: time.sleep(6) if connect_server_times &amp;gt; 20: print(&amp;#039;连接服务器失败,请检查网络或联系管理员&amp;#039;) return [False, &amp;#039;连接服务器失败,请检查网络或联系管理员&amp;#039;] api_complete_path = random.choice(api_list) + api connect_server_times += 1 print(f&amp;#039;尝试第【{connect_server_times}】次连接服务器&amp;#039;) # 获取时间戳 timestamp = get_net_timestamp(&amp;#039;taobao&amp;#039;) param[&amp;#039;timestamp&amp;#039;] = timestamp param[&amp;#039;sign&amp;#039;] = hex_md5(api_password + str(timestamp)) try: response = requests.post(api_complete_path, data=param, timeout=10) server_return_json = response.text except Exception as e: server_return_json = &amp;#039;&amp;#039; if server_return_json[2:6] == &amp;quot;code&amp;quot;: break try: server_return_data = response.json() except Exception: return [False, &amp;#039;返回数据格式错误&amp;#039;] if server_return_data.get(&amp;#039;code&amp;#039;) == 0: return [False, server_return_data.get(&amp;#039;msg&amp;#039;, &amp;#039;未知错误&amp;#039;)] # 签名校验 server_sign = server_return_data.get(&amp;#039;sign&amp;#039;, &amp;#039;&amp;#039;) server_timestamp = server_return_data.get(&amp;#039;timestamp&amp;#039;, 0) valid_sign = hex_md5(str(server_timestamp) + api_password) time_diff = abs(int(timestamp) - int(server_timestamp)) if server_sign != valid_sign or time_diff &amp;gt; 600: return [False, &amp;#039;算法验证错误,请联系管理员&amp;#039;] return [True, server_return_data.get(&amp;#039;data&amp;#039;)] def card_ping(): while True: ping_result = ql_request(&amp;#039;apiv3/card_ping&amp;#039;, { &amp;#039;card&amp;#039;: card, &amp;#039;needle&amp;#039;: local_storage.get(&amp;#039;card_login_needle&amp;#039;, &amp;#039;&amp;#039;) }) if ping_result[0]: print(&amp;#039;最新的卡密到期时间:&amp;#039;, ping_result[1][&amp;#039;endtime&amp;#039;]) print(&amp;#039;最新的卡密剩余时间:&amp;#039;, ping_result[1][&amp;#039;less_time&amp;#039;]) heartbeat_sec = int(ping_result[1].get(&amp;#039;heartbeat_second&amp;#039;, 60)) time.sleep(heartbeat_sec) else: print(&amp;#039;心跳失败,失败原因是:&amp;#039;, ping_result[1]) break # 心跳失败后退出循环,线程自然结束 def card_login(): global card result = ql_request(&amp;#039;apiv3/card_login&amp;#039;, {&amp;#039;card&amp;#039;: card}) if result[0]: print(&amp;#039;卡密到期时间:&amp;#039;, result[1][&amp;#039;endtime&amp;#039;]) print(&amp;#039;卡密剩余时间:&amp;#039;, result[1][&amp;#039;less_time&amp;#039;]) print(&amp;#039;卡密类型为:&amp;#039;, result[1][&amp;#039;type&amp;#039;]) # 存储 needle 并启动心跳线程 local_storage[&amp;#039;card_login_needle&amp;#039;] = result[1][&amp;#039;needle&amp;#039;] threading.Thread(target=card_ping, daemon=True).start() else: print(&amp;#039;卡密登录失败,失败原因是:&amp;#039;, result[1]) # 执行登录 card_login() while(True): time.sleep(1); print(&amp;#039;主线程&amp;#039;)</code></pre>

页面列表

ITEM_HTML