A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 唐伯虎(0) 中级黑马   /  2018-11-29 12:59  /  1335 人查看  /  0 人回复  /   1 人收藏 转载请遵从CC协议 禁止商业使用本文

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()

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马