日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

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

發布時間:2023/12/18 python 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 利用Python制作王者战力查询以及皮肤查看软件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

根據下面的提供的王者榮耀最低戰力查詢的Python源碼,使用PYQT5搭建了一個GUI,同時還可以看每個英雄皮膚的高清圖。

""" 當然在學習Python的道路上肯定會困難,沒有好的學習資料,怎么去學習呢? 學習Python中有不明白推薦加入交流Q群號:928946953 群里有志同道合的小伙伴,互幫互助, 群里有不錯的視頻學習教程和PDF! 還有大牛解答! """ import requests as r import random import jsondef getMidStr(txt, txt_start, txt_end='', seeks=0, seeke=0):"""取中間文本函數"""try:if txt_end or seeks or seeke:passelse:raise 1s_1 = txt.find(txt_start)if s_1 == -1:raise 1l_1 = len(txt_start)if txt_end:s_2 = txt.find(txt_end, s_1)if s_1 == -1 or s_2 == -1:return Falsereturn 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)continuetitle = _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' # 替換為自己申請的akurl = "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教程心Python代碼:

from multiprocessing import Pool import sys import time from bs4 import BeautifulSoup from PyQt5.QtGui import QBrush, QIcon, QMouseEvent, QPalette, QPixmap from PyQt5.QtCore import pyqtSignal, Qt, QRect, QSize, QThread from PyQt5.QtWidgets import QApplication, QCompleter, QGraphicsOpacityEffect, QGroupBox,\QHBoxLayout, QLineEdit, QPushButton, QVBoxLayout, QWidget import requests import sip # 引入自定義組件 from custom_widgets.CustomQLabel import CustomQLabel from custom_widgets.PowerDisplayArea import PowerDisplayArea from custom_widgets.SkinBox import SkinBox from custom_widgets.WarnMessagebox import WarnMessagebox # 引入自定義函數 from functions.get_detail_location import get_detail_location from functions.get_heroSkin_url import heroSkin, download_image_data from functions.get_power_information import get_power_info# 讀取qss文件并設置stylesheet class QssTool:@staticmethoddef set_qss(obj, filepath):with open(filepath, 'r', encoding='utf-8') as f:style = f.read()obj.setStyleSheet(style)class RunThread(QThread):"""該線程用于下載圖片數據以及獲取地名詳情信息"""_signal = pyqtSignal(object)def __init__(self, hero, qq_info, wx_info):super(RunThread, self).__init__()self.hero = heroself.qq_info = qq_infoself.wx_info = wx_infodef __del__(self):self.wait()def run(self):print('線程開始')self.load_data(self.hero, self.qq_info, self.wx_info)def load_data(self, hero, qq_info, wx_info):"""1. 調用 heroSkin 獲取英雄皮膚以及縮略圖網址,然后在線程池中下載圖片數據2. 調用 get_detail_location 補全定位所在省份或者市級:param hero::param qq_info::param wx_info::return:"""small_skin, big_skin, num = heroSkin(hero) # 爬取高清皮膚、縮略圖網址,以及皮膚數量pool = Pool(2 * (num-1)) # 利用線程池下載皮膚高清圖以及縮放圖數據rl = pool.map(download_image_data, big_skin + small_skin)pool.close() # 關閉進程池,不再接受新的進程pool.join() # 主進程阻塞等待子進程的退出img_data = rl# 補全地區信息qq_detail_place = [get_detail_location(qq_item['定位']) for qq_item in qq_info]wx_detail_place = [get_detail_location(wx_item['定位']) for wx_item in wx_info]return_data = {'big_skin': img_data[:num],'small_skin': img_data[num:],'qq_detail_place': qq_detail_place,'wx_detail_place': wx_detail_place,'qq_info': qq_info,'wx_info': wx_info,}self._signal.emit(return_data)# 主程序 class App(QWidget):def __init__(self, parent=None):super(App, self).__init__(parent)# 應用布局 美化QssTool.set_qss(self, 'beautify.qss')self.setWindowTitle("王者戰力查詢")# 設置窗口背景pixmap = QPixmap()pixmap.load("./image/199-bigskin-3.jpg")pixmap = pixmap.scaled(960, 441, Qt.KeepAspectRatio, Qt.SmoothTransformation)palette = QPalette()palette.setBrush(QPalette.Background, QBrush(pixmap))self.setPalette(palette)self.mainLayout = QVBoxLayout(self)self.mainLayout.setContentsMargins(0, 0, 0, 0)self.mainLayout.addStretch()# 顯示皮膚頭像的布局self.thumbnailLayout = QHBoxLayout()self.thumbnailLayout.addStretch()self.smallLayout = QHBoxLayout()self.smallLayout.setContentsMargins(0, 0, 0, 0)self.smallLayout.setSpacing(10)self.thumbnailLayout.addLayout(self.smallLayout)self.thumbnailLayout.addStretch()self.mainLayout.addLayout(self.thumbnailLayout)self.setLayout(self.mainLayout)self.container = QGroupBox(self)self.container.setObjectName('container')self.container.setGeometry(QRect(340, 250, 280, 280))self.lay = QVBoxLayout()self.search_box_area = QGroupBox(self)self.search_box_area.setObjectName('searchBox')self.search_box_layout = QHBoxLayout()self.search_box_layout.setSpacing(0)self.search_box_layout.setContentsMargins(5, 0, 5, 0)self.channel = CustomQLabel(self)self.channel.button_clicked_signal.connect(self.channel_Changed)self.inputBox = QLineEdit(self)self.inputBox.setObjectName('inputBox')self.inputBox.setPlaceholderText('輸入英雄名稱')self.inputBox.setAlignment(Qt.AlignCenter)self.btn = QPushButton('', self)self.btn.setIcon(QIcon('./image/scope1.png'))self.btn.setObjectName('searchButton')self.btn.setIconSize(QSize(30, 30))self.btn.setFixedSize(QSize(36, 36))self.btn.clicked.connect(self.search)self.search_box_layout.addWidget(self.channel)self.search_box_layout.addWidget(self.inputBox)self.search_box_layout.addWidget(self.btn)self.search_box_area.setLayout(self.search_box_layout)layout = QHBoxLayout()layout.addStretch()layout.addWidget(self.search_box_area)layout.addStretch()self.lay.addLayout(layout)self.container.setLayout(self.lay)self.lay.addSpacing(20)self.wid = PowerDisplayArea()self.wid.setInfo('省標')self.lay.addWidget(self.wid)self.wid2 = PowerDisplayArea()self.wid2.setInfo('市標')self.lay.addWidget(self.wid2)self.wid3 = PowerDisplayArea()self.wid3.setInfo('縣標')self.lay.addWidget(self.wid3)self.wid.hide()self.wid2.hide()self.wid3.hide()self.container.setStyleSheet('''QGroupBox{background-color:transparent;}''')self.status = Falseself.start()def start(self):url = 'https://pvp.qq.com/web201605/herolist.shtml'headers = {'content-type': 'text/html','user-agent': '''Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36'''}total_list = requests.get(url, headers)total_list.encoding = 'GBK'soup = BeautifulSoup(total_list.text, 'html.parser')hero_names = soup.select('div[class="herolist-content"]')soup2 = BeautifulSoup(str(hero_names), 'html.parser')hero_names = soup2.find_all('a')hero_list = [item.get_text() for item in hero_names]# 增加自動補全completer = QCompleter(hero_list)# 設置匹配模式completer.setFilterMode(Qt.MatchStartsWith)# 設置補全模式completer.setCompletionMode(QCompleter.InlineCompletion)# 給LineEdit設置補全器self.inputBox.setCompleter(completer)def search(self):hero = self.inputBox.text()if hero == "":warnBox = WarnMessagebox()warnBox.set_position(self.pos().x() + 380, self.pos().y() + 145)warnBox.exec_()else:try:self.s1 = time.time()self.setWindowTitle("王者戰力查詢 (查詢中)")qq_info, wx_info = get_power_info(hero)self.thread = RunThread(hero, qq_info, wx_info)self.thread._signal.connect(self.call_backlog)# 開始線程self.thread.start()except Exception as reason:print("沒有英雄:%s" % reason)warnBox = WarnMessagebox()warnBox.set_position(self.pos().x() + 380, self.pos().y() + 145)warnBox.exec_()def call_backlog(self, data):self.container.setGeometry(QRect(340, 80, 280, 280))self.container.setStyleSheet('''QGroupBox#container{background-color:white;border-radius:10px;}''')opacity = QGraphicsOpacityEffect()opacity.setOpacity(0.7)self.container.setGraphicsEffect(opacity)self.inputBox.setStyleSheet('''QLineEdit#inputBox {border:none;border-right:2px solid #7F7F7F;background-color:transparent;font-size:12pt;font-family:"微軟雅黑";color:gray;}''')self.search_box_area.setStyleSheet('''QGroupBox#searchBox{border:2px solid #7F7F7F;}''')self.btn.setIcon(QIcon('./image/scope2.png'))self.qq_info, self.wx_info = data['qq_info'], data['wx_info']# 設置窗口背景self.imgData = data['big_skin']pixmap = QPixmap()pixmap.loadFromData(self.imgData[0])pixmap = pixmap.scaled(960, 441, Qt.KeepAspectRatio, Qt.SmoothTransformation)palette = QPalette()palette.setBrush(QPalette.Background, QBrush(pixmap))self.setPalette(palette)# -----------如果有頭像框,刷新前清除------------for i in reversed(range(self.smallLayout.count())):w = self.smallLayout.itemAt(i)w.widget().deleteLater()self.smallLayout.removeItem(w)sip.delete(w.widget())sip.delete(self.smallLayout)self.smallLayout = QHBoxLayout()# ----------重新生成縮略圖區---------------------------------SkinBox.numInstance = 0for i, skin in enumerate(data['small_skin']):self.skinBox = SkinBox()self.skinBox.setMouseTracking(True)self.skinBox.setObjectName(str(i))self.skinBox.setSkin(skin, 'q' + str(i))self.smallLayout.addWidget(self.skinBox)self.skinBox.num_send_signal.connect(self.get_object_name)self.thumbnailLayout.insertLayout(1, self.smallLayout)# ------獲取地區信息---------self.qq_detailPlace = data['qq_detail_place']self.wx_detailPlace = data['wx_detail_place']# -------設置戰力數據--------self.status = Trueself.show_information(self.channel.getStatus())self.wid.show()self.wid2.show()self.wid3.show()self.setWindowTitle("王者戰力查詢")self.s2 = time.time()print('time', self.s2 - self.s1)del self.threaddef channel_Changed(self):if self.status:self.show_information(not self.channel.getStatus())def show_information(self, IsWx):if IsWx:self.wid.setInfo('省標', self.wx_info[2]['戰力'], self.wx_info[2]['定位'], self.wx_info[2]['更新時間'],self.wx_detailPlace[2])self.wid2.setInfo('市標', self.wx_info[1]['戰力'], self.wx_info[1]['定位'], self.wx_info[1]['更新時間'],self.wx_detailPlace[1])self.wid3.setInfo('縣標', self.wx_info[0]['戰力'], self.wx_info[0]['定位'], self.wx_info[0]['更新時間'],self.wx_detailPlace[0])else:self.wid.setInfo('省標', self.qq_info[2]['戰力'], self.qq_info[2]['定位'], self.qq_info[2]['更新時間'],self.qq_detailPlace[2])self.wid2.setInfo('市標', self.qq_info[1]['戰力'], self.qq_info[1]['定位'], self.qq_info[1]['更新時間'],self.qq_detailPlace[1])self.wid3.setInfo('縣標', self.qq_info[0]['戰力'], self.qq_info[0]['定位'], self.qq_info[0]['更新時間'],self.qq_detailPlace[0])self.lay.addWidget(self.wid)self.lay.addWidget(self.wid2)self.lay.addWidget(self.wid3)strNum = 0def get_object_name(self, object_name):"""1. 根據對象名稱,得到 SkinBox 中對應縮略圖的索引2. 如果索引發生改變,則將新的索引值所對應的皮膚設置為當前界面背景:param object_name::return:"""list_str = list(object_name)list_str.pop(0)object_name = ''.join(list_str)if int(object_name) != self.strNum:self.strNum = int(object_name)pixmap = QPixmap()pixmap.loadFromData(self.imgData[self.strNum])pixmap = pixmap.scaled(960, 441, Qt.KeepAspectRatio, Qt.SmoothTransformation)palette = QPalette()palette.setBrush(QPalette.Background, QBrush(pixmap))self.setPalette(palette)else:passdef mouseMoveEvent(self, a0: QMouseEvent):self.setMouseTracking(True)if __name__ == "__main__":import ctypes # 解決任務欄ico無法顯示的問題ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("myappid")app = QApplication(sys.argv)form = App()form.setFixedSize(960, 441)form.setWindowIcon(QIcon('image/2021.ico'))form.show()sys.exit(app.exec_())

總結

以上是生活随笔為你收集整理的利用Python制作王者战力查询以及皮肤查看软件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产天堂一区 | 日韩视频一区在线观看 | 男女黄色网| 99这里有精品 | 色婷婷av一区二区 | 神马午夜影院 | 亚洲国产一二三 | 久久久久久久久黄色 | 欧美h在线观看 | 国产视频一区二区在线播放 | 亚洲视频入口 | 日韩中文一区 | 黄色网址视频在线观看 | 久久99精品久久久久久琪琪 | 午夜性色| 日本中文字幕在线播放 | 秋霞三区| 又黄又爽无遮挡 | 99r热| 99riav国产精品 | 亚洲桃色av| 日韩av一二三区 | 国产精选中文字幕 | 污视频网站在线观看 | 深夜福利日韩 | 日韩区在线观看 | 国产一级视频在线 | 日韩精品一区在线视频 | 久久综合亚洲色hezyo国产 | 五月婷婷丁香 | 日韩激情一区二区三区 | 欧美www.| 偷拍欧美另类 | 亚洲三级在线免费观看 | 蜜臀久久99精品久久久画质超高清 | 日本阿v视频在线观看 | 亚洲精品三级 | 深夜在线免费视频 | 亚洲午夜精选 | 亚洲成人伦理 | 在线观看av片 | 亚洲一区二区三区蜜桃 | 午夜日韩精品 | 95看片淫黄大片一级 | 亚洲成熟少妇 | 天天干天天操天天摸 | 成人亚洲黄色 | 自拍露脸高潮 | 古代黄色片 | 97人人爽人人爽人人爽 | 一区二区三区精彩视频 | 中文高清av| 看一级黄色片 | 五月婷婷激情网 | 97自拍网 | 日韩啪啪网 | av资源站 | 亚洲作爱网 | 国产老头老太作爱视频 | 漂亮少妇高潮午夜精品 | 欧美高清| 99在线观看 | 日韩欧美成人一区二区三区 | 中文字幕免费av | 国产麻豆一区二区 | 美国性生活大片 | 台湾综合色 | 欧美福利片在线观看 | а 天堂 在线 | 九色自拍视频 | 日韩电影中文字幕 | 人人色网| 91色吧| 1000部拍拍拍18勿入免费视频 | 男人操女人逼逼视频 | 国产乱人对白 | caoporn国产| 亚洲一区影院 | 亚洲综合二区 | 男男做爰猛烈啪啪高 | 在线观看9.1 | 日本午夜精华 | 不卡欧美 | 99热这里只有精品8 国产一卡二 | 欧美久久久久久久久久 | 精品国产欧美日韩 | 香蕉视频黄色在线观看 | 国精无码欧精品亚洲一区蜜桃 | 国产女主播在线一区二区 | 日韩中文字幕第一页 | 国产中文在线视频 | 性猛交╳xxx乱大交 偷偷操不一样的久久 | 女人18毛片水真多 | 欧美日韩亚洲一区二区三区 | 国产一级视频 | 国产毛片91 | 88av在线播放| 国产精品美女毛片真酒店 | 国产在线视视频有精品 |