mirror of
https://git.oceanpay.cc/danial/kami_walmart_card.git
synced 2025-12-18 22:35:54 +00:00
71 lines
2.3 KiB
Python
71 lines
2.3 KiB
Python
import hashlib
|
|
import json
|
|
import time
|
|
|
|
import requests
|
|
|
|
|
|
class CheckMoney:
|
|
|
|
def __init__(self, cookies):
|
|
self.cookies = cookies
|
|
self.url = "https://apicard.swiftpass.cn/app/card/mem/more/consume.json"
|
|
|
|
def md5_encrypt(self, data):
|
|
# 创建 MD5 哈希对象
|
|
md5_hash = hashlib.md5()
|
|
# 更新哈希对象以包含数据
|
|
md5_hash.update(data.encode('utf-8')) # 确保数据为字节类型
|
|
# 返回十六进制表示的大写 MD5 值
|
|
return md5_hash.hexdigest().upper()
|
|
|
|
def query_balance(self):
|
|
timestamp = f"{int(time.time() * 1000)}"
|
|
data = '{"bizType":2,"currentPage":0,"pageSize":0,"sign":"%s"}%saab23c732038417795a0f5caf70899b7' % (
|
|
self.cookies, timestamp
|
|
)
|
|
signature = self.md5_encrypt(data)
|
|
headers = {
|
|
"Host": "apicard.swiftpass.cn",
|
|
"version": "16",
|
|
"timestamp": f"{timestamp}",
|
|
"signature": signature,
|
|
"xweb_xhr": "1",
|
|
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090c2d)XWEB/11581",
|
|
"content-type": "application/json",
|
|
"accept": "*/*",
|
|
"sec-fetch-site": "cross-site",
|
|
"sec-fetch-mode": "cors",
|
|
"sec-fetch-dest": "empty",
|
|
"referer": "https://servicewechat.com/wx81d3e1fe4c2e11b4/158/page-frame.html",
|
|
"accept-language": "zh-CN,zh;q=0.9"
|
|
}
|
|
data = {
|
|
"bizType": 2,
|
|
"currentPage": 0,
|
|
"pageSize": 0,
|
|
"sign": self.cookies
|
|
}
|
|
data = json.dumps(data, separators=(',', ':'))
|
|
response = requests.post(self.url, headers=headers, data=data)
|
|
return response.json()
|
|
|
|
def run(self):
|
|
res = self.query_balance()
|
|
print(res)
|
|
balance = res["data"]["balanceCnt"]
|
|
return {
|
|
"code": 100,
|
|
"data": {
|
|
"balance": balance
|
|
}
|
|
}
|
|
|
|
|
|
if __name__ == '__main__':
|
|
cookies = "5761d1dfeea1422990c7f0dace26dcd8@853540263801a118ff85ec686f23bbd7"
|
|
res = CheckMoney(
|
|
cookies=cookies
|
|
).run()
|
|
print(res)
|