LOL皮肤下载
```import requests
import os
import jsonpath
from urllib.request import urlretrieve
#皮肤保存在D盘先在D盘新建一个lolskins空文件夹
headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'}
def get_ids():
url='https://game.gtimg.cn/images/lol/act/img/js/heroList/hero_list.js'
r=requests.get(url,headers=headers).json()
ids=jsonpath.jsonpath(r,'$..heroId')
print('共有英雄',len(ids))
return ids
def get_skins(ids):
for id in ids:
hero_url='https://game.gtimg.cn/images/lol/act/img/js/hero/{}.js'.format(id)
hero_data=requests.get(hero_url,headers=headers).json()
skins=hero_data['skins']
names=jsonpath.jsonpath(skins,'$..name') #每个英雄皮肤的所有名字
images=jsonpath.jsonpath(skins,'$..mainImg') #每个英雄的所有皮肤
try:
if not os.path.exists(names):
os.mkdir('D:/lolskins/'+names)
for name,image in zip(names,images):
urlretrieve(image,'D:/lolskins/'+names+'/'+name+'.jpg')
except:
pass
print(f'{names}下载成功')
if __name__ == '__main__':
ids=get_ids()
get_skins(ids)
``` 新手刚开始爬虫。忘记上传图片了 Oranger 发表于 2020-12-14 23:15
新手刚开始爬虫。忘记上传图片了
怎么玩的? wangshuo3545 发表于 2020-12-19 14:22
怎么玩的?
电脑上得安张python才行
页:
[1]