UIGF-org / mihoyo-api-collect

收集米哈游旗下的游戏与应用的API。
Other
344 stars 31 forks source link

获取验证码貌似失效了 #45

Closed SC0624a closed 7 months ago

SC0624a commented 7 months ago

如题,详情如下(python 3.11.8)

import requests as fw
import time

class times:
    def ss():
        time_stamp = time.time()
        return int(time_stamp)

    def ms():
        time_stamp = time.time()
        return round(time_stamp * 1000)

def mihayou_index(phon_id):
    url = f"https://webapi.account.mihoyo.com/Api/create_mmt?scene_type=1&now={times.ms()}&reason=user.mihoyo.com%2523%252Flogin%252Fcaptcha&action_type=login_by_mobile_captcha"
    a = fw.get(url)
    k = a.json()["data"]["mmt_data"]["mmt_key"]
    t = a.json()["data"]["mmt_type"]
    if t == 1:
        print("尝试人机验证\n请您稍后再试")
    elif k != "":
        send_mihayou_msg(mmt_key=k,mobile=phon_id)
        print(k + "\n" + phon_id + "\n" + str(t))
    else:
        print(a.json())

def send_mihayou_msg(mmt_key,mobile):
    ua = "Mozilla/5.0 (Linux; Android 5.1.1; vivo X9 Plus Build/LMY48Z) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36"
    url = f"https://webapi.account.mihoyo.com/Api/create_mobile_captcha action_type=login&mmt_key={mmt_key}&mobile={mobile}%&t={times.ms()}"
    data = {"User-Agent":ua}
    a = fw.post(url,json=data)
    if a.json()["data"]["status"] == -454:
        print("失败")
    else:
        try:
            msg = a.json()["data"]["msg"]
            print(msg + "\n成功")
        except KeyError:
            print(a.json())

mihayou_index(phon_id="XXXXX")

返回如下

{'code': 400, 'data': {'status': -404}}

Lightczx commented 7 months ago

image caa23413433a8b1ff5dee836a80cda12