吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2910|回复: 8
收起左侧

[Python 原创] 【原创源码】【Python】利用Lcu Api制作的lol大乱斗Buff提示软件

[复制链接]
LEOVVVVVVV 发表于 2022-7-9 17:01
本帖最后由 LEOVVVVVVV 于 2022-7-9 21:01 编辑

了解吾爱很久了,从最最最开始的在论坛里找各位老哥做的工具,到现在自己也很感兴趣,亲自体验一下代码的魅力。作为一个外行人,虽然写的软件功能很简单,但是对我自己来说还是成就感满满的啦学Python以来自己制作的第一个案例
感谢论坛老哥叫我ChEn1啦丶分享的Lcuapi的用法,经过自己摸索终于写出来了
效果图如下

下面附上源码,由于是小白,很多地方可能写的不规范,希望各位大佬指点指点吧。
[Python] 纯文本查看 复制代码
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:LEOV

# 导入模块区
import ctypes
import json
import os
import re
import time
import webbrowser
import requests
import subprocess
import sys
import threading
import tkinter as tk

# 以下代码可避免requests模块运行时报错
requests.packages.urllib3.disable_warnings()
requests.DEFAULT_RETRIES = 1000

# 设置变量区
cmd01 = r'WMIC PROCESS WHERE name="LeagueClientUx.exe" GET commandline'  # cmd运行的命令,此命令可获取指定程序的启动参数
cmd02 = 'wmic process where name="LeagueClientUx.exe" get processid,executablepath,name'  # 检测lol客户端进程
# api查询地址 https://lcu.vivide.re/
api01 = "/lol-summoner/v1/current-summoner"  # 获取用户信息
api02 = '/lol-gameflow/v1/session'  # 获取对局信息-可在房间信息内找到英雄id
api03 = '/lol-champ-select-legacy/v1/session'  # 获取当前选择英雄的ID-大乱斗用不了
api04 = '/lol-champ-select/v1/session'  # 获取选择的英雄,可以通过召唤师ID确认,我的id是2973112230
heroID = None

# ---------------函数区--------------
# 获取管理员权限
def is_admin():
    try:
        return ctypes.windll.shell32.IsUserAnAdmin()  # 此代码可获取管理员权限并重新执行本文件
    except:
        return True


# LcuApi相关函数
class Lcuapi():
    def checklol(self):
        '''
        检测进程是否存在
        :return:
        '''
        res = subprocess.Popen(cmd02,
                               shell=True,
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE,
                               )
        res.wait()  # 等待子进程结束
        # temp = res.returncode  # 检查cmd是否成功
        temp = res.communicate()  # 获取cmd输出内容
        temp = re.findall('LeagueClientUx.exe', str(temp))
        time.sleep(1)  # 设置延迟,1秒检测一次游戏进程
        if temp:
            print('检测到游戏进程')
            return True
        else:
            print('游戏未开始')
            return False

    def runcmd(self):
        '''
        运行CMD命令获得程序启动参数
        :return:程序启动项
        '''
        print('开始获取端口')
        res = os.popen(cmd01)  # 执行cmd命令,此处不能使用subprocess,因为获取端口需要管理员权限
        temp = res.read()  # 获得输出字符串
        print('已获取到启动参数为:', temp)
        return temp

    def lol_PT(self):
        '''
        提取端口及秘钥
        :return: lol_token,lol_port
        '''
        temp = self.runcmd()
        getlol = re.findall(r'remoting-auth-token=\S{22}', temp)  # 匹配密码字符
        getlol += re.findall(r'--app-port=\d{5}', temp)  # 匹配端口字符
        print('已提取出关键信息:', getlol)
        lol_token = str(getlol[0]).replace('remoting-auth-token=', '')
        print('获得密匙为:' + lol_token)
        lol_port = str(getlol[1]).replace('--app-port=', '')
        print('获得端口号为:' + lol_port)
        return lol_port, lol_token

    def runapi(self, api, lol_PT):
        """
        获取给予API返回的值
        :return: getapi
        """
        port = lol_PT[0]
        token = lol_PT[1]
        getapi = requests.get(
            url="https://riot:" + token + '@127.0.0.1:' + port + api,
            verify=False)
        print('当前api地址为:'"https://riot:" + token + '@127.0.0.1:' + port + api)
        print(getapi.json())
        return getapi

    def getheroID(self, js, puuid):
        '''
        从房间信息json中解析到当前选择的英雄ID
        :param js:
        :return: 前选择的英雄ID
        '''
        for temp in js.json()['myTeam']:
            if temp['summonerId'] == puuid:
                print('当前召唤师ID:', temp['summonerId'])
                break
        return temp['championId']


def getbuff():
    '''
    从网页或者文件中读取json
    :return:
    '''
    a = True  # 如果a = False从网页中读取buff信息
    if a:
        read = open('lol.json', mode='r', encoding="utf-8")
        buff = json.load(read)
        print('已从文件获取到buff数据')
    else:
        buff = requests.get(
            url="https://leov.top/lol.json",
            verify=False).json()
        print('已从服务器获取到buff数据')
    return buff


def color(a):
    '''
    输出,护盾,治疗buff颜色
    :param a:
    :return:
    '''
    a = int(a)
    if a > 100:
        return '#75ff72'
    elif a < 100:
        return '#790000'
    else:
        return '#ffffff'


def color02(a):
    '''
    承伤buff颜色
    :param a:
    :return:
    '''
    a = int(a)
    if a < 100:
        return '#75ff72'
    elif a > 100:
        return '#790000'
    else:
        return '#ffffff'


def xiangqing():
    '''
    前往英雄详情页
    :return:
    '''
    try:
        url = f'https://101.qq.com/#/hero-detail?heroid={heroID}&datatype=fight'
        webbrowser.open(url, new=0, autoraise=True)
    except:
        return None


# tk面板搭建
def mianban():
    # 主面板搭建
    global root, l01, l02, l03, l04, l06, l07, l08, l09, b01
    root = tk.Tk()  # 设置主面板
    root.title('乱斗小助手v1.01')  # 设置窗口名称
    root.geometry('465x230+1280+720')  # 设置窗口大小
    root.resizable(height=False, width=False)  # 禁止调整窗口长宽
    print('窗口搭建完成!')

    # 第一个窗体
    frame1 = tk.Frame(root, relief='raised', borderwidth=1)
    frame1.pack(side='top', fill='both', ipadx=1, ipady=1, expand=0)
    # 第二个窗体
    frame2 = tk.Frame(root, relief='raised', borderwidth=1)
    frame2.pack(side='top', fill='both', ipadx=1, ipady=1, expand=0)
    # 第三个窗体
    frame3 = tk.Frame(root, relief='raised', borderwidth=5)
    frame3.pack(side='top', fill='both', ipadx=1, ipady=1, expand=0)
    # 第四个窗体
    frame4 = tk.Frame(root, relief='raised', borderwidth=1)
    frame4.pack(side='top', fill='both', ipadx=1, ipady=1, expand=0)

    # 定义一个lable,显示召唤师信息用的
    l01 = tk.Label(
        frame1,  # 选择窗口
        # 显示内容
        text='',
        bg='#e1f3ff',  # 背景颜色
        font=('Microsoft YaHei', 12),  # 字体及文字大小
        width=50,  # 宽度
        height=4,  # 高度
        justify='left'  # 多行文本对齐方式
    )
    l01.pack(fill='both')  # 固定到窗口

    # 定义一个lable,显示当前游戏模式
    l02 = tk.Label(
        frame2,  # 选择窗口
        text='',  # 显示内容
        # bg='gray',  # 背景颜色
        font=('Microsoft YaHei', 13),  # 字体及文字大小
        width=18,  # 宽度
        height=2,  # 高度
        justify='left'
    )
    l02.pack(side='left', anchor='center', fill='both')  # 固定到窗口
    # 定义按钮,直达英雄详情页
    b01 = tk.Button(
        frame2,
        text="前往英雄详情页",
        bg='#e1f3ff',
        command=xiangqing
    )
    b01.pack(side='left', anchor='center', fill='both')

    # 定义一个lable,显示当前游戏模式
    l03 = tk.Label(
        frame2,  # 选择窗口
        text='',  # 显示内容
        # bg='gray',  # 背景颜色
        font=('Microsoft YaHei', 13),  # 字体及文字大小
        width=20,  # 宽度
        height=2,  # 高度
        justify='left'
    )
    l03.pack(side='right', anchor='center', fill='both')  # 固定到窗口ipadx=10,ipady=10分别表示与其他容器的间距

    # 定义一个lable,显示伤害buff
    l06 = tk.Label(
        frame3,  # 选择窗口
        text='',  # 显示内容
        bg='gray',  # 背景颜色
        font=('Microsoft YaHei', 12),  # 字体及文字大小
        width=10,  # 宽度
        height=2,  # 高度
        justify='left'
    )
    l06.pack(side='left', anchor='center', fill='both')  # 固定到窗口ipadx=10,ipady=10分别表示与其他容器的间距
    # 定义一个lable,做分割线
    line02 = tk.Label(
        frame3,  # 选择窗口
        # bg='blue',  # 背景颜色
        width=1,  # 宽度
        # height=2,  # 高度
    )
    line02.pack(side='left', fill='both')
    # 定义一个lable,显示承伤buff
    l07 = tk.Label(
        frame3,  # 选择窗口
        text='',  # 显示内容
        bg='gray',  # 背景颜色
        font=('Microsoft YaHei', 12),  # 字体及文字大小
        width=10,  # 宽度
        height=2,  # 高度
        justify='left'
    )
    l07.pack(side='left', anchor='center', fill='both')  # 固定到窗口ipadx=10,ipady=10分别表示与其他容器的间距

    # 定义一个lable,做分割线
    line03 = tk.Label(
        frame3,  # 选择窗口
        # bg='blue',  # 背景颜色
        width=1,  # 宽度
        # height=2,  # 高度
    )
    line03.pack(side='left', fill='both')

    # 定义一个lable,显示护盾buff
    l08 = tk.Label(
        frame3,  # 选择窗口
        text='',  # 显示内容
        bg='gray',  # 背景颜色
        font=('Microsoft YaHei', 12),  # 字体及文字大小
        width=10,  # 宽度
        height=2,  # 高度
        justify='left'
    )
    l08.pack(side='left', anchor='center', fill='both')  # 固定到窗口ipadx=10,ipady=10分别表示与其他容器的间距

    # 定义一个lable,做分割线
    line04 = tk.Label(
        frame3,  # 选择窗口
        # bg='blue',  # 背景颜色
        width=1,  # 宽度
        # height=2,  # 高度
    )
    line04.pack(side='left', fill='both')

    # 定义一个lable,显示治疗buff
    l09 = tk.Label(
        frame3,  # 选择窗口
        text='',  # 显示内容
        bg='gray',  # 背景颜色
        font=('Microsoft YaHei', 12),  # 字体及文字大小
        width=10,  # 宽度
        height=2,  # 高度
        justify='left'
    )
    l09.pack(side='left', anchor='center', fill='both')  # 固定到窗口ipadx=10,ipady=10分别表示与其他容器的间距

    # 定义一个lable,显示当前游戏进程
    l04 = tk.Label(
        frame4,  # 选择窗口
        text='',  # 显示内容
        # bg='gray',  # 背景颜色
        font=('Microsoft YaHei', 10),  # 字体及文字大小
        # width=21,  # 宽度
        height=1,  # 高度
    )
    l04.pack(side='left', fill='both')  # 固定到窗口

    # 定义一个lable,显示作者信息
    l05 = tk.Label(
        frame4,  # 选择窗口
        text='by:LEOV',  # 显示内容
        # bg='gray',  # 背景颜色
        font=('Microsoft YaHei', 10),  # 字体及文字大小
        width=21,  # 宽度
        height=1,  # 高度

    )
    l05.pack(side='right', fill='both')  # 固定到窗口


def yunxing():
    '''
    1、使用runapi函数调用api
    2、解析api返回值
    3、循环调用并刷新界面数据
    解析并设置
    :return:
    '''
    # 声明变量
    global r1, r2, r3, api01, api02, api03
    # 运行函数调用api
    if lcu.checklol():  # 如果游戏执行成功
        lol_PT = lcu.lol_PT()
        r1 = lcu.runapi(api01, lol_PT)  # 获取召唤师基本信息
        r2 = lcu.runapi(api02, lol_PT)  # 获取对局信息
        r3 = lcu.runapi(api04, lol_PT)  # 获取选择英雄
        a4 = '游戏已运行'
        # 解析召唤师信息
        try:
            a1 = (f"召唤师名称: {r1.json()['displayName']}\n" +
                  f"召唤师等级: {r1.json()['summonerLevel']}\n" +
                  f"当前PUUID: {r1.json()['puuid']}\n" +
                  f"当前AccountID: {r1.json()['accountId']}"
                  )
        except:
            a1 = '暂未开始游戏'

        # 解析游戏模式
        try:
            a2 = (f'''      
游戏地图:
{r2.json()["map"]["gameModeName"]}
                    ''')
        except:
            a2 = ('暂未开始游戏')
            print(a2)

        # 解析当前选择英雄ID,并对照服务器json获得英雄名称
        try:
            temp = lcu.getheroID(r3,r1.json()['accountId'])
            global heroID
            heroID = temp
            a3 = f'''当前选择的英雄:
{buff[str(temp)]["name"]}'''
        except:
            a3 = ('暂未选择英雄')
            print(a3)
    else:
        a1 = a2 = a3 = a4 = '未检测到游戏进程'

    # 伤害buff
    try:
        a6 = [f'''伤害buff:{buff[str(temp)]["out"]}''', buff[str(temp)]["out"]]
    except:
        a6 = [None, 100]
    try:
        a7 = [f'''承伤buff:{buff[str(temp)]["input"]}''', buff[str(temp)]["input"]]
    except:
        a7 = [None, 100]
    try:
        a8 = [f'''护盾buff:{buff[str(temp)]["shield"]}''', buff[str(temp)]["shield"]]
    except:
        a8 = [None, 100]
    try:
        a9 = [f'''治疗buff:{buff[str(temp)]["cure"]}''', buff[str(temp)]["cure"]]
    except:
        a9 = [None, 100]
    # 设置文本刷新
    l04.config(text=a4)  # 检测游戏进程
    l01.configure(text=a1)  # 用户信息
    l02.configure(text=a2)  # 游戏房间信息
    l03.configure(text=a3)  # 选择英雄信息
    # 以下设置buff提示
    l06.configure(text=a6[0], bg=color(a6[1]))  # 伤害buff
    l07.configure(text=a7[0], bg=color02(a7[1]))  # 承伤buff
    l08.configure(text=a8[0], bg=color(a8[1]))  # 护盾buff
    l09.configure(text=a9[0], bg=color(a9[1]))  # 治疗buff

    root.after(500, yunxing)  # 进入循环,每0.5秒刷新一次


# 如果不是管理员,此代码将获取管理员权限并重新执行本文件
# 此段代码在IDE环境需开启管理员权限,否则无效,需打包exe后可自动获取管理员权限
if not is_admin():
    ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)  # 获取管理员权限并重新执行本文件

else:  # 下面放成为管理员后执行的代码
    buff = getbuff()
    mianban()
    lcu = Lcuapi()  # 实例化lcu函数
    # 使用子线程获取api信息
    t2 = threading.Thread(target=yunxing, args=())
    # start 之后,子线程开始执行,主线程也会继续执行,不会等待
    t2.start()
    root.mainloop()  # 设置窗口循环

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| LEOVVVVVVV 发表于 2022-7-11 12:07
Avenshy 发表于 2022-7-9 18:59
太强了,感谢分享,话说有使用的截图吗,想看一下效果
还有就是这个算外卦吗,有封号风险吗

不是外挂,调用lol官方API获取的信息,然后进行比对显示,不涉及游戏内存修改,符合官方绿色插件公约要求,截图的话这有旧版的,新版添加了个跳转到官方数据网页的按钮

 楼主| LEOVVVVVVV 发表于 2022-7-9 17:07
运行需要的buff数据在这,使用脚本爬取lol官网获取英雄列表然后手动填的,其他方法不会,只会这个笨办法了真正的人工智能

此处是填好的json数据
[JavaScript] 纯文本查看 复制代码
{
    "1":{
        "name":"黑暗之女",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "2":{
        "name":"狂战士",
        "out":95,
        "input":95,
        "shield":100,
        "cure":120
    },
    "3":{
        "name":"正义巨像",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "4":{
        "name":"卡牌大师",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "5":{
        "name":"德邦总管",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "6":{
        "name":"无畏战车",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "7":{
        "name":"诡术妖姬",
        "out":110,
        "input":90,
        "shield":100,
        "cure":100
    },
    "8":{
        "name":"猩红收割者",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "9":{
        "name":"远古恐惧",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "10":{
        "name":"正义天使",
        "out":95,
        "input":103,
        "shield":100,
        "cure":100
    },
    "11":{
        "name":"无极剑圣",
        "out":100,
        "input":97,
        "shield":100,
        "cure":100
    },
    "12":{
        "name":"牛头酋长",
        "out":95,
        "input":110,
        "shield":100,
        "cure":80
    },
    "13":{
        "name":"符文法师",
        "out":110,
        "input":90,
        "shield":100,
        "cure":100
    },
    "14":{
        "name":"亡灵战神",
        "out":92,
        "input":108,
        "shield":80,
        "cure":100
    },
    "15":{
        "name":"战争女神",
        "out":85,
        "input":105,
        "shield":100,
        "cure":100
    },
    "16":{
        "name":"众星之子",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "17":{
        "name":"迅捷斥候",
        "out":90,
        "input":110,
        "shield":100,
        "cure":100
    },
    "18":{
        "name":"麦林炮手",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "19":{
        "name":"祖安怒兽",
        "out":105,
        "input":95,
        "shield":100,
        "cure":100
    },
    "20":{
        "name":"雪原双子",
        "out":108,
        "input":92,
        "shield":100,
        "cure":100
    },
    "21":{
        "name":"赏金猎人",
        "out":90,
        "input":110,
        "shield":100,
        "cure":100
    },
    "22":{
        "name":"寒冰射手",
        "out":85,
        "input":110,
        "shield":100,
        "cure":100
    },
    "23":{
        "name":"蛮族之王",
        "out":110,
        "input":85,
        "shield":100,
        "cure":120
    },
    "24":{
        "name":"武器大师",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "25":{
        "name":"堕落天使",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "26":{
        "name":"时光守护者",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "27":{
        "name":"炼金术士",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "28":{
        "name":"痛苦之拥",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "29":{
        "name":"瘟疫之源",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "30":{
        "name":"死亡颂唱者",
        "out":90,
        "input":100,
        "shield":100,
        "cure":100
    },
    "31":{
        "name":"虚空恐惧",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "32":{
        "name":"殇之木乃伊",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "33":{
        "name":"披甲龙龟",
        "out":105,
        "input":90,
        "shield":100,
        "cure":100
    },
    "34":{
        "name":"冰晶凤凰",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "35":{
        "name":"恶魔小丑",
        "out":105,
        "input":100,
        "shield":100,
        "cure":100
    },
    "36":{
        "name":"祖安狂人",
        "out":95,
        "input":110,
        "shield":100,
        "cure":100
    },
    "37":{
        "name":"琴瑟仙女",
        "out":85,
        "input":115,
        "shield":60,
        "cure":60
    },
    "38":{
        "name":"虚空行者",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "39":{
        "name":"刀锋舞者",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "40":{
        "name":"风暴之怒",
        "out":95,
        "input":105,
        "shield":90,
        "cure":90
    },
    "41":{
        "name":"海洋之灾",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "42":{
        "name":"英勇投弹手",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "43":{
        "name":"天启者",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "44":{
        "name":"瓦洛兰之盾",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "45":{
        "name":"邪恶小法师",
        "out":95,
        "input":105,
        "shield":100,
        "cure":100
    },
    "48":{
        "name":"巨魔之王",
        "out":100,
        "input":105,
        "shield":100,
        "cure":95
    },
    "50":{
        "name":"诺克萨斯统领",
        "out":90,
        "input":106,
        "shield":100,
        "cure":100
    },
    "51":{
        "name":"皮城女警",
        "out":100,
        "input":95,
        "shield":100,
        "cure":100
    },
    "53":{
        "name":"蒸汽机器人",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "54":{
        "name":"熔岩巨兽",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "55":{
        "name":"不祥之刃",
        "out":110,
        "input":90,
        "shield":100,
        "cure":100
    },
    "56":{
        "name":"永恒梦魇",
        "out":110,
        "input":90,
        "shield":100,
        "cure":120
    },
    "57":{
        "name":"扭曲树精",
        "out":85,
        "input":110,
        "shield":100,
        "cure":60
    },
    "58":{
        "name":"荒漠屠夫",
        "out":105,
        "input":95,
        "shield":100,
        "cure":120
    },
    "59":{
        "name":"德玛西亚皇子",
        "out":105,
        "input":95,
        "shield":100,
        "cure":100
    },
    "60":{
        "name":"蜘蛛女皇",
        "out":108,
        "input":92,
        "shield":100,
        "cure":100
    },
    "61":{
        "name":"发条魔灵",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "62":{
        "name":"齐天大圣",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "63":{
        "name":"复仇焰魂",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "64":{
        "name":"盲僧",
        "out":110,
        "input":90,
        "shield":120,
        "cure":120
    },
    "67":{
        "name":"暗夜猎手",
        "out":100,
        "input":93,
        "shield":100,
        "cure":100
    },
    "68":{
        "name":"机械公敌",
        "out":105,
        "input":95,
        "shield":100,
        "cure":100
    },
    "69":{
        "name":"魔蛇之拥",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "72":{
        "name":"水晶先锋",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "74":{
        "name":"大发明家",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "75":{
        "name":"沙漠死神",
        "out":100,
        "input":105,
        "shield":100,
        "cure":100
    },
    "76":{
        "name":"狂野女猎手",
        "out":110,
        "input":100,
        "shield":100,
        "cure":100
    },
    "77":{
        "name":"兽灵行者",
        "out":110,
        "input":85,
        "shield":110,
        "cure":100
    },
    "78":{
        "name":"圣锤之毅",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "79":{
        "name":"酒桶",
        "out":100,
        "input":97,
        "shield":100,
        "cure":100
    },
    "80":{
        "name":"不屈之枪",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "81":{
        "name":"探险家",
        "out":95,
        "input":103,
        "shield":100,
        "cure":100
    },
    "82":{
        "name":"铁铠冥魂",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "83":{
        "name":"牧魂人",
        "out":95,
        "input":105,
        "shield":100,
        "cure":100
    },
    "84":{
        "name":"离群之刺",
        "out":110,
        "input":90,
        "shield":100,
        "cure":100
    },
    "85":{
        "name":"狂暴之心",
        "out":100,
        "input":95,
        "shield":100,
        "cure":100
    },
    "86":{
        "name":"德玛西亚之力",
        "out":100,
        "input":95,
        "shield":100,
        "cure":100
    },
    "89":{
        "name":"曙光女神",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "90":{
        "name":"虚空先知",
        "out":110,
        "input":85,
        "shield":100,
        "cure":100
    },
    "91":{
        "name":"刀锋之影",
        "out":110,
        "input":92,
        "shield":100,
        "cure":100
    },
    "92":{
        "name":"放逐之刃",
        "out":105,
        "input":92,
        "shield":120,
        "cure":100
    },
    "96":{
        "name":"深渊巨口",
        "out":90,
        "input":108,
        "shield":100,
        "cure":100
    },
    "98":{
        "name":"暮光之眼",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "99":{
        "name":"光辉女郎",
        "out":85,
        "input":110,
        "shield":80,
        "cure":100
    },
    "101":{
        "name":"远古巫灵",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "102":{
        "name":"龙血武姬",
        "out":100,
        "input":95,
        "shield":100,
        "cure":100
    },
    "103":{
        "name":"九尾妖狐",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "104":{
        "name":"法外狂徒",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "105":{
        "name":"潮汐海灵",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "106":{
        "name":"不灭狂雷",
        "out":100,
        "input":95,
        "shield":100,
        "cure":100
    },
    "107":{
        "name":"傲之追猎者",
        "out":108,
        "input":92,
        "shield":100,
        "cure":120
    },
    "110":{
        "name":"惩戒之箭",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "111":{
        "name":"深海泰坦",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "112":{
        "name":"机械先驱",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "113":{
        "name":"北地之怒",
        "out":105,
        "input":92,
        "shield":100,
        "cure":100
    },
    "114":{
        "name":"无双剑姬",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "115":{
        "name":"爆破鬼才",
        "out":80,
        "input":105,
        "shield":100,
        "cure":100
    },
    "117":{
        "name":"仙灵女巫",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "119":{
        "name":"荣耀行刑官",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "120":{
        "name":"战争之影",
        "out":110,
        "input":90,
        "shield":100,
        "cure":120
    },
    "121":{
        "name":"虚空掠夺者",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "122":{
        "name":"诺克萨斯之手",
        "out":100,
        "input":95,
        "shield":100,
        "cure":120
    },
    "126":{
        "name":"未来守护者",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "127":{
        "name":"冰霜女巫",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "131":{
        "name":"皎月女神",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "133":{
        "name":"德玛西亚之翼",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "134":{
        "name":"暗黑元首",
        "out":105,
        "input":100,
        "shield":100,
        "cure":100
    },
    "136":{
        "name":"铸星龙王",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "141":{
        "name":"影流之镰",
        "out":105,
        "input":100,
        "shield":100,
        "cure":100
    },
    "142":{
        "name":"暮光星灵",
        "out":105,
        "input":95,
        "shield":100,
        "cure":100
    },
    "143":{
        "name":"荆棘之兴",
        "out":90,
        "input":105,
        "shield":100,
        "cure":100
    },
    "145":{
        "name":"虚空之女",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "147":{
        "name":"星籁歌姬",
        "out":85,
        "input":115,
        "shield":60,
        "cure":60
    },
    "150":{
        "name":"迷失之牙",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "154":{
        "name":"生化魔人",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "157":{
        "name":"疾风剑豪",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "161":{
        "name":"虚空之眼",
        "out":95,
        "input":105,
        "shield":100,
        "cure":100
    },
    "163":{
        "name":"岩雀",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "164":{
        "name":"青钢影",
        "out":105,
        "input":95,
        "shield":120,
        "cure":100
    },
    "166":{
        "name":"影哨",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "200":{
        "name":"虚空女皇",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "201":{
        "name":"弗雷尔卓德之心",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "202":{
        "name":"戏命师",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "203":{
        "name":"永猎双子",
        "out":110,
        "input":90,
        "shield":100,
        "cure":100
    },
    "221":{
        "name":"祖安花火",
        "out":100,
        "input":95,
        "shield":100,
        "cure":100
    },
    "222":{
        "name":"暴走萝莉",
        "out":90,
        "input":105,
        "shield":100,
        "cure":100
    },
    "223":{
        "name":"河流之王",
        "out":105,
        "input":115,
        "shield":100,
        "cure":100
    },
    "234":{
        "name":"破败之王",
        "out":105,
        "input":95,
        "shield":100,
        "cure":100
    },
    "235":{
        "name":"涤魂圣枪",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "236":{
        "name":"圣枪游侠",
        "out":103,
        "input":100,
        "shield":100,
        "cure":100
    },
    "238":{
        "name":"影流之主",
        "out":105,
        "input":92,
        "shield":100,
        "cure":100
    },
    "240":{
        "name":"暴怒骑士",
        "out":105,
        "input":90,
        "shield":100,
        "cure":100
    },
    "245":{
        "name":"时间刺客",
        "out":105,
        "input":95,
        "shield":100,
        "cure":100
    },
    "246":{
        "name":"元素女皇",
        "out":115,
        "input":85,
        "shield":100,
        "cure":100
    },
    "254":{
        "name":"皮城执法官",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "266":{
        "name":"暗裔剑魔",
        "out":105,
        "input":90,
        "shield":100,
        "cure":100
    },
    "267":{
        "name":"唤潮鲛姬",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "268":{
        "name":"沙漠皇帝",
        "out":110,
        "input":95,
        "shield":100,
        "cure":100
    },
    "350":{
        "name":"魔法猫咪",
        "out":103,
        "input":100,
        "shield":100,
        "cure":100
    },
    "360":{
        "name":"沙漠玫瑰",
        "out":100,
        "input":95,
        "shield":100,
        "cure":100
    },
    "412":{
        "name":"魂锁典狱长",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "420":{
        "name":"海兽祭司",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "421":{
        "name":"虚空遁地兽",
        "out":120,
        "input":85,
        "shield":100,
        "cure":120
    },
    "427":{
        "name":"翠神",
        "out":95,
        "input":100,
        "shield":100,
        "cure":100
    },
    "429":{
        "name":"复仇之矛",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "432":{
        "name":"星界游神",
        "out":115,
        "input":80,
        "shield":100,
        "cure":20
    },
    "497":{
        "name":"幻翎",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "498":{
        "name":"逆羽",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "516":{
        "name":"山隐之焰",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "517":{
        "name":"解脱者",
        "out":100,
        "input":95,
        "shield":100,
        "cure":100
    },
    "518":{
        "name":"万花通灵",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "523":{
        "name":"残月之肃",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "526":{
        "name":"镕铁少女",
        "out":95,
        "input":105,
        "shield":90,
        "cure":90
    },
    "555":{
        "name":"血港鬼影",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "711":{
        "name":"愁云使者",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    },
    "777":{
        "name":"封魔剑魂",
        "out":103,
        "input":97,
        "shield":100,
        "cure":100
    },
    "875":{
        "name":"腕豪",
        "out":95,
        "input":105,
        "shield":90,
        "cure":90
    },
    "876":{
        "name":"含羞蓓蕾",
        "out":95,
        "input":100,
        "shield":100,
        "cure":100
    },
    "887":{
        "name":"灵罗娃娃",
        "out":105,
        "input":95,
        "shield":100,
        "cure":100
    },
    "888":{
        "name":"炼金男爵",
        "out":100,
        "input":100,
        "shield":100,
        "cure":100
    }
}

 楼主| LEOVVVVVVV 发表于 2022-7-9 17:11
然后是爬取lol英雄ID的代码,拥有英雄名称跟英雄id后就可以根据lcuapi获取到的id匹配从而得到英雄名称了
[Python] 纯文本查看 复制代码
"""
网址:https://game.gtimg.cn/images/lol/act/img/js/heroList/hero_list.js
目标:获取所有英雄的名称和英雄ID
数据结构:json
数据请求方式:ajax
"""
import requests

url  = 'https://game.gtimg.cn/images/lol/act/img/js/heroList/hero_list.js'
temp = 0#设置计数变量
headers_ = {
'Referer': 'https://lol.qq.com/',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 Safari/537.36',
}

response = requests.get(url=url,headers=headers_).json()
# print(response)
json_data = response['hero']
note = open('lol.json', mode ='w',encoding='utf-8')
note.write('{')
for j in json_data:
    heroId= j['heroId']
    hero_name = j['name']
    detail_url = f'https://game.gtimg.cn/images/lol/act/img/js/hero/{heroId}.js'
    skill_response = requests.get(url=detail_url,headers=headers_).json()
    skills_list = skill_response['spells']
    ls_=[]
    for skill in skills_list:
        skills = skill['name']
        ls_.append(skills)
    #制作json
    a = '{'
    b = '}'
    r =(f'''"{str(heroId)}":{a}"name":"{str(hero_name)}","out":100,"input":100,"shield":100,"cure":100{b}''')
    print(r)
    note.write(r)
    temp += 1
    if temp < len(json_data):
        note.write(',')
note.write('}')
Avenshy 发表于 2022-7-9 18:59
太强了,感谢分享,话说有使用的截图吗,想看一下效果
还有就是这个算外卦吗,有封号风险吗
灵剑丹心 发表于 2022-7-9 19:04
buff提示干什么的,效果图看看
 楼主| LEOVVVVVVV 发表于 2022-7-9 21:05
灵剑丹心 发表于 2022-7-9 19:04
buff提示干什么的,效果图看看

忘了上图了,更新了,等待审核
Avenshy 发表于 2022-7-13 12:27
LEOVVVVVVV 发表于 2022-7-11 12:07
不是外挂,调用lol官方API获取的信息,然后进行比对显示,不涉及游戏内存修改,符合官方绿色插件公约要求 ...

哥哥太厉害了
family0_0 发表于 2024-1-20 15:25
不错,就是把队友英雄跟备选的英雄也显示就更好了,不过有源码,闲着的时候自己改一下也行
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-24 17:25

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表