Spider爬取英雄联盟官网皮肤图片
是从这里开始找的英雄联盟资料库
感觉还能更优化一点,哈哈!
参考了这位大哥的一点点代码
--------> 使用python爬取英雄联盟的图片
下面展示 spider代码
。
'''爬取官网所有英雄的所有皮肤'''
import requests
import time
import os
import json
class LOLSpider:
def __init__(self):
self.url='https://game.gtimg.cn/images/lol/act/img/js/heroList/hero_list.js'
self.headers={
"User-Agnet":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36"}
# 转换文件格式
def get_pic_url(self):
# 转换图片文件的格式为 python格式
pic_js=json.loads(requests.get(url=self.url,headers=self.headers).text)
# print(pic_js['hero'])
for hero in pic_js['hero']:
# print(hero)