利用Python制作王者战力查询以及皮肤查看软件

根据下面的提供的王者荣耀最低战力查询的Python源码,使用PYQT5搭建了一个GUI,同时还可以看每个英雄皮肤的高清图。

"""
当然在学习Python的道路上肯定会困难,没有好的学习资料,怎么去学习呢? 
学习Python中有不明白推荐加入交流Q群号:928946953 
群里有志同道合的小伙伴,互帮互助, 群里有不错的视频学习教程和PDF!
还有大牛解答!
"""
import requests as r
import random
import 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 即可)


  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值