Python大神完成王者榮耀助手助力菜鳥,網友評論:不用擔心被噴了

狄仁傑
首先找到三個介面
第一個是英雄武器的介面
# 武器URL地址
>weapon_url = "http://gamehelper.gm825.com/wzry/equip/list"
第二個是英雄列表介面
# 英雄列表URL地址
>heros_url = "http://gamehelper.gm825.com/wzry/hero/list"
第三個是英雄出裝的介面
第三個介面有點特殊,需要前面的英雄id,也就是hero_id
># 英雄出裝URL >hero_url = "http://gamehelper.gm825.com/wzry/hero/detail?hero_id={}".format(hero_id)
下面就是愉快的程式碼之旅了~
>首先匯入兩個庫 from urllib.request import urlretrieve import requests
先熱熱身,通過urllib下載王者榮耀得英雄圖片,下面是部分程式碼:

Python大神完成王者榮耀助手助力菜鳥,網友評論:不用擔心被噴了
執行後下載圖片:
接下來是獲取英雄的名字和ID,程式碼如下:
執行效果如圖所示:
這個時候執行會有一些問題,seek_weapon函式還沒有定義,接下來定義seek_weapon,程式碼如下:
seek_weapon函式在呼叫的時候,需要weapon_info,也就是所有武器的字典,這個時候就需要在定義一個函式來獲取武器的字典
另附headers
headers = { 'Accept-Charset': 'UTF-8', 'Accept-Encoding': 'gzip,deflate', 'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 6.0.1; MI 5 MIUI/V8.1.6.0.MAACNDI)', 'X-Requested-With': 'XMLHttpRequest', 'Content-type': 'application/x-www-form-urlencoded', 'Connection': 'Keep-Alive', 'Host': 'gamehelper.gm825.com' }
最終的執行效果下圖:

結果
需要相關檔案程式碼,喜歡+轉發然後私信加群:718492558獲取