大佬们帮我看看这个python报错的什么怎么解决呀
这个要怎么解决啊 求帮忙 :'(weeqw:'(weeqw 你就给个报错截图,代码都没有,能给你解决就有鬼了。而且报错不是说的很明白了吗,取不到data,data,下面的game_token,
你把data输出看一下就知道了 登录的用户名或者密码错误,或者是登录模块写的有问题导致登录失败。 下面不是写着了吗,date的key"date"的value的null,null哪来的"game_token" 做个判断 retcode 为 -100 时
就不要去取 data 了 你学的是什么教程,能说一下吗,
你要粘贴更多代码 多半被反扒了,像上面坛友说的,‘data’:‘null’,没取到你要的game_token,要么就做个异常判断咯,要么打印看看什么原因data为null
代码如下 是搬的站内大佬的 但是我没学过python 能不能看一下报错怎么解决:'(weeqw
import json
import time
import cv2
from pyzbar.pyzbar import decode
import pyzbar.pyzbar as pyzbar
import numpy as np
import tkinter as tk
import threading
import re
import http.client
import win32gui
import win32ui
import win32con
import uuid
# 当前抢码游戏 原神=4,星穹铁道=8
GameType = 4
# 填写米游社cookie
cookie = "stuid=344590715;stoken=_MHYUUID=e5253e36-0f21-4b0a-89e8-e29d5ca74934; _MHYUUID=e5253e36-0f21-4b0a-89e8-e29d5ca74934; DEVICEFP_SEED_ID=7e4d39d93f2ced9a; DEVICEFP_SEED_TIME=1685187876511; _ga=GA1.1.866323409.1685187877; DEVICEFP=38d7eea56c05e; _ga_KS4J8TXSHQ=GS1.1.1685187876.1.1.1685187877.0.0.0; LOGIN_PLATFORM_SWITCH_STATUS={%22bll8iq97cem8%22:{%22qr_login%22:false%2C%22sms_login_tab%22:true%2C%22pwd_login_tab%22:true%2C%22password_reset_entry%22:true}}; cookie_token_v2=v2_XkxWNuUaYLWNNr8wwb2P9WDh1SYxoNSukjBLir6AKpQF7gyPtcLQ0OKXeMn41Du99YxMKR0OPG25eWAjhJt3886EF21XRjyL_wMYn799NpninKLHOV6Z8w==; account_mid_v2=00uetabsn7_mhy; account_id_v2=344590715; ltoken_v2=v2_5nnHsBbIuRF_7jUdwLWD_HJ5xscC8IPyunDkPxl-RiWEEmsuY6-fDnleWbsdmRtjQqV5MnbCDbcdbVIGyFZP2r1dv5REhfdPaQ==; ltmid_v2=00uetabsn7_mhy; ltuid_v2=344590715;mid=0mmmmato08_mhy;"
# cookie格式stuid=xxxxxxx;stoken=v2_xxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=;mid=0mmmmato08_mhy;
# stuid为米游社UID非游戏内UID
# stoken需要此参数
# mid=0mmmmato08_mhy需要此参数
# 填写米游社uid
uid = "344590715"
# uid为米游社UID非游戏内UID可以使用上方的stuid
# 获取UUID
def get_uuid():
get_timestamp_uuid = uuid.uuid1()# 根据时间戳生成uuid,保证全球唯一
return str(get_timestamp_uuid)
# 随机获取一个UUID来作为device
device = get_uuid()
# 显示框框
def my_function():
# 创建一个Tkinter窗口
root = tk.Tk()
# 隐藏窗口标题栏和边框
root.overrideredirect(True)
# 将窗口置顶
root.wm_attributes("-topmost", True)
# 设置窗口大小和位置
win_width = 300
win_height = 300
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x_pos = (screen_width // 2) - (win_width // 2)
y_pos = (screen_height // 2) - (win_height // 2)
root.geometry('{}x{}+{}+{}'.format(win_width, win_height, x_pos, y_pos))
# 将窗口背景设为透明
root.attributes('-transparentcolor', 'white')
# 将窗口的画布设为透明
canvas = tk.Canvas(root, bg='white', highlightthickness=0)
canvas.pack(fill='both', expand=True)
# 绘制一个红色空心正方形
canvas.create_rectangle(
5, 5, win_width - 5, win_height - 5, outline='red', width=2)
# 进入循环让窗口保持打开状态
root.mainloop()
# 启动线程
my_thread = threading.Thread(target=my_function)
my_thread.start()
# 设置扫描区域
width, height = 300, 300
# 获取屏幕尺寸
screen_width = tk.Tk().winfo_screenwidth()
screen_height = tk.Tk().winfo_screenheight()
# 计算识别区域左上角
left = (screen_width - width) // 2
top = (screen_height - height) // 2
# 计算识别区右下角
right = left + width
bottom = top + height
# 获取屏幕DC
hwnd = win32gui.GetDesktopWindow()
hdc = win32gui.GetWindowDC(hwnd)
dc = win32ui.CreateDCFromHandle(hdc)
def capture_screen():
saveDC = dc.CreateCompatibleDC()
# 创建位图对象
saveBitMap = win32ui.CreateBitmap()
saveBitMap.CreateCompatibleBitmap(dc, right - left, bottom - top)
# 将位图选入到DC中
saveDC.SelectObject(saveBitMap)
# 截屏并保存到位图中
saveDC.BitBlt((0, 0), (right - left, bottom - top),
dc, (left, top), win32con.SRCCOPY)
# 将位图对象转换为numpy数组并进行颜色空间转换
bmpinfo = saveBitMap.GetInfo()
bmpstr = saveBitMap.GetBitmapBits(True)
screenshot = np.frombuffer(bmpstr, dtype='uint8').reshape(
(bmpinfo['bmHeight'], bmpinfo['bmWidth'], 4))[:, :, :3]
screenshot = cv2.cvtColor(screenshot, cv2.COLOR_BGR2GRAY)
# 释放资源
saveDC.DeleteDC()
win32gui.DeleteObject(saveBitMap.GetHandle())
return screenshot
# 抢码开始
def Request(ticket):
conn = http.client.HTTPSConnection("api-sdk.mihoyo.com")
payload = json.dumps({
"app_id": GameType,
"device": device,
"ticket": ticket
})
headers = {}
if GameType == 4:# 原神
conn.request("POST", "/hk4e_cn/combo/panda/qrcode/scan", payload, headers)
elif GameType == 8:# 星穹铁道
conn.request("POST", "/hkrpg_cn/combo/panda/qrcode/scan", payload, headers)
res = conn.getresponse()
data = res.read()
data = json.loads(data.decode("utf-8"))
retcode = data["retcode"]
return retcode
# 确认登陆
def ConfirmRequest(ticket):
conn = http.client.HTTPSConnection("api-takumi.miyoushe.com")
payload = ''
headers = {
'cookie': cookie,
}
conn.request("GET", "/auth/api/getGameToken",
'', headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
data = json.loads(data.decode("utf-8"))
token = data["data"]["game_token"]
conn = http.client.HTTPSConnection("api-sdk.mihoyo.com")
payload = json.dumps({
"app_id": GameType,
"device": device,
"payload": {
"proto": "Account",
"raw": f"{{\"uid\":\"{uid}\",\"token\":\"{token}\"}}"
},
"ticket": ticket
})
headers = {
'cookie': cookie,
}
conn.request("POST", "/hk4e_cn/combo/panda/qrcode/confirm",
payload, headers)
res = conn.getresponse()
# data = res.read()
# print(data.decode("utf-8"))
# 记录FPS开始时间
frame_count = 0
frame_start_time = time.time()
while True:
# 截取指定区域的屏幕截图
# 将截图转换为灰度图像
screenshot = capture_screen()
# 尝试使用pyzbar库识别二维码
codes = decode(screenshot, symbols=)
# 如果找到了二维码,输出其内容
if codes:
print("扫码成功!")
pattern = r"ticket=(+)"
match = re.search(pattern, codes.data.decode())
# 正则请求地址
if match:
print(match.group(1))
# 进入抢码
start_time = time.time()
retcode = Request(match.group(1))
end_time = time.time()
if retcode == 0:
# 计算代码执行时间并输出
elapsed_time = end_time - start_time
print("抢码成功耗时 %.3f 秒" % elapsed_time)
random = 1.3
time.sleep(random)
print("防止过快被察觉插入随机延迟")
# 确认登陆
start_time = time.time()
ConfirmRequest(match.group(1))
end_time = time.time()
# 计算代码执行时间并输出
elapsed_time = end_time - start_time
print("确认登陆成功耗时 %.3f 秒" % elapsed_time)
# print("作者by:吾爱破解tseed")
# 等待一下
time.sleep(1)
else:
print("未知二维码抢码失败")
# 等待一下
time.sleep(1)
# 记录每秒帧数
frame_count += 1
if time.time() - frame_start_time >= 1:
fps = frame_count
print(f"FPS:{fps}" + "\r", end='', flush=True)
frame_count = 0
frame_start_time = time.time()
# 在窗口中显示截图
cv2.imshow("QR Code Scanner", screenshot)
# 检查是否按下了键盘上的任意键
if cv2.waitKey(1) != -1:
break
# 关闭窗口
cv2.destroyAllWindows()
GMCN 发表于 2023-5-28 00:47
你就给个报错截图,代码都没有,能给你解决就有鬼了。
而且报错不是说的很明白了吗,取不到data,data,下 ...
大佬,代码发出来了 你看一下 446598 发表于 2023-5-29 08:48
大佬,代码发出来了 你看一下
没玩过你这个,帮你调试不了,你按照上面吾友的说法自己调试一下吧
页:
[1]