根据下面的提供的王者荣耀最低战力查询的Python源码,使用PYQT5搭建了一个GUI,同时还可以看每个英雄皮肤的高清图。
私信小编01即可获取大量Python学习资源
import requests as rimport randomimport json def getMidStr(txt, txt_start, txt_end='', seeks=0, seeke=0): """取中间文本函数""" try: if txt_end or seeks or seeke: pass else: raise 1 s_1 = txt.find(txt_start) if s_1 == -1: raise 1 l_1 = len(txt_start) if txt_end: s_2 = txt.find(txt_end, s_1) if s_1 == -1 or s_2 == -1: return False return txt[s_1 + l_1:s_2] if seeks: return txt[s_1 - seeks:s_1] if seeke: return txt[s_1 + l_1:s_1 + l_1 + seeke] except Exception: return '传参错误或未找到传参文本' while True: hero = input("输入需要查询的英雄:") if hero == "": print("您输入无效") elif hero == "0": exit() else: source = r.get("http://s.wukongfenshen.com:9972/main/api/honour/wzpower/static/js/index.js?v=0." + str( random.randint(1000000, 9999999))).text _json = getMidStr(source, "var dictAll = ", "}}") + "}}" _json = json.loads(_json) try: _json[hero] except KeyError as reason: print("没有英雄:%s" % reason) continue title = _json[hero]["title"] content = _json[hero]["content"] print("英雄:%s" % title) content = str.replace(content, "<p><p>", "n") content = str.replace(content, "<p> <p>", "n") content = str.replace(content, "</p>", "n") content = str.replace(content, "<p>", "") print(content + "n")
如果想更换主界面背景,修改第90行的图片路径即可。
pixmap.load("./image/199-bigskin-3.jpg")
搜索框输入想查询的英雄名称,带有自动补全。英雄查询失败,或者名字不正确,则会被提示
点击搜索,搜索时间有时较长有时较短,我也不知道为什么。结果界面如下,背景默认为原皮皮肤,可以移动鼠标位置到缩略图上,即可将该皮肤设置为背景。
点击QQ头像即可切换到微信区
鼠标停留在地区上,则会显示所属省份或市级(该功能默认关闭,因为需调用百度地图api, 使用前要自己去申请相应的 ak, 申请后将functions文件夹下get_detail_location.py 中的 ak 替换为自己的 ak 即可)
def get_detail_location(place_name): ak = 'ckXXxxxxxxxxxxxxxxxxcO9' # 替换为自己申请的ak url = "http://api.map.baidu.com/place/v2/suggestion" + f"?query={place_name}?ion={place_name}&city_limit=false&output=json&ak={ak}" res = requests.get(url).json() return res['result'][0]['province'] + res['result'][0]['city']
核心Python代码:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!