import requests import json
headers = { ‘user-agent‘: ‘Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1‘
} #所以英雄的url url = ‘https://lol.qq.com/biz/hero/champion.js‘
resp = requests.get(url,headers)
data = resp.content.decode()[len(‘if(!LOLherojs)var LOLherojs={};LOLherojs.champion=‘):-1]
item = json.loads(data)[‘data‘] for i in item: #英雄的名字 print(‘[英雄的名字]‘+item[‘title‘]+‘-‘+item[‘name‘])
# Mage - 法师 # Assassin - 刺客 # Fighter - 战士 # Tank - 坦克 # Support - 辅助 # Marksman-射手 dat = {‘Mage‘:‘法师‘,‘Assassin‘:‘刺客‘,‘Fighter‘:‘战士‘,‘Tank‘:‘坦克‘,‘Support‘:‘辅助‘,‘Marksman‘:‘射手‘} tags=‘[英雄的分类]‘ for a in item[‘tags‘]: tags+=(dat[a]+‘ ‘) print(tags)
#英雄图片地址 print(‘[英雄图片地址]‘+‘ https://ossweb-img.qq.com/images/lol/img/champion/‘+item[‘image‘][‘full‘]) #英雄详情页地址 # print(‘[英雄详情页地址]‘+‘https://lol.qq.com/biz/hero/{}.js‘.format(item[‘id‘]))
#获取英雄皮肤 img_data= requests.get(url = ‘https://lol.qq.com/biz/hero/{}.js‘.format(item[‘id‘]),headers=headers) imgs = img_data.content.decode() img = json.loads(imgs[img_data.content.decode().find(‘data‘) - 2:-1])
for i in img[‘data‘][‘skins‘]: if i[‘name‘] == ‘default‘: i[‘name‘] = ‘默认‘ print(‘[{}皮肤]‘.format(i[‘name‘])+‘ http://ossweb-img.qq.com/images/lol/web201310/skin/big{}.jpg‘.format(i[‘id‘]))
#英雄的技能 for i in img[‘data‘][‘spells‘]:
print(‘[技能图片] ‘+‘https://ossweb-img.qq.com/images/lol/img/spell/‘+i[‘image‘][‘full‘]) print(‘[技能名称] ‘+i[‘name‘]) # print(‘[技能说明] ‘+i[‘description‘]) print(‘[技能说明] ‘+i[‘tooltip‘]) try: print(‘[技能伤害] ‘+i[‘leveltip‘][‘effect‘][0])
print(‘[技能消耗] ‘+i[‘leveltip‘][‘effect‘][1]) except: pass #英雄的被动技能 print(‘[被动图片] ‘+‘https://ossweb-img.qq.com/images/lol/img/passive/‘+img[‘data‘][‘passive‘][‘description‘]) print(‘[被动名称] ‘+img[‘data‘][‘passive‘][‘name‘]) print(‘[被动说明] ‘+img[‘data‘][‘passive‘][‘description‘]) print() print(‘[背景故事] ‘+img[‘data‘][‘lore‘]) print() print(‘[使用技巧-当你使用九尾妖狐] ‘+img[‘data‘][‘lore‘]) print() print(‘[使用技巧-敌人使用九尾妖狐] ‘+str(img[‘data‘][‘enemytips‘]))
#推荐装备 for i in img[‘data‘][‘blocks‘][0][‘recommended‘]: for ii in i[‘items‘]: print(‘[召唤师峡谷] ‘ +‘https://ossweb-img.qq.com/images/lol/img/item/‘+ ii[‘id‘]+‘.png‘)
for ii in img[‘data‘][‘blocks‘][0][‘recommended‘]: for ii in i[‘items‘]: print(‘[极地大乱斗] ‘ + ‘https://ossweb-img.qq.com/images/lol/img/item/‘ + ii[‘id‘]+‘.png‘)
print() |