首页 游戏攻略文章正文

英雄联盟皮肤下载_英雄联盟皮肤站

游戏攻略 2021年12月20日 09:52 8088 admin

想要LOL皮肤高清图吗?Python助你获得。

(此次爬虫代码是搬运来的)

英雄联盟皮肤下载_英雄联盟皮肤站  第1张

来点高清图镇楼:

源码私信小编007!

英雄联盟皮肤下载_英雄联盟皮肤站  第2张

代码如次:

import refrom urllib import requestimport threadingimport osimport jsonfrom queue import Queueclass Procuder(threading.Thread): ''' 获得每个皮肤及原画的链接和名字''' def __init__(self, hero_queue, img_queue, *args, **kwargs): super(Procuder, self).__init__(*args, **kwargs) self.hero_queue = hero_queue self.img_queue = img_queue def run(self): while True: if self.hero_queue.empty(): break url = self.hero_queue.get() self.parser_page(url) def parser_page(self, url): response = request.urlopen(url) data = response.read().decode('utf-8') # print(data) skin_json = re.findall(r'{"data":(.*?);', data) # print(skin_json) skin_jsons = '{"data":' + skin_json[0] skin = json.loads(skin_jsons) default = skin['data']['name'] skins = skin['data']['skins'] for key in skins: if key['name'] == 'default': imgname = default # print(imgname) else: imgname = key['name'] imgid = key['id'] # print(imgid,imgname) imgname = re.sub(r'/', '', imgname) # 替代K/AD save_name = "F://Downloads//lolskin//" + imgname + '.jpg' img_url = "http://ossweb-img.qq.com/images/lol/web201310/skin/big" + imgid + ".jpg" self.img_queue.put((img_url, save_name))class Consumer(threading.Thread): '''对获得到的贯穿举行载入''' def __init__(self, hero_queue, img_queue, *args, **kwargs): super(Consumer, self).__init__(*args, **kwargs) self.hero_queue = hero_queue self.img_queue = img_queue def run(self): while True: if self.hero_queue.empty() and self.img_queue.empty(): break img_url, save_name = self.img_queue.get() try: if not os.path.exists(save_name): request.urlretrieve(img_url, save_name) print("载入实行") except Exception: print("载入波折")def main(): hero_queue = Queue(150) res = request.urlopen('http://lol.qq.com/biz/hero/champion.js') text = res.read().decode('utf-8') hero_lists = re.findall(r'LOLherojs.champion=(.+?);', text) hero_dic = json.loads(hero_lists[0])['keys'] # 豪杰确定页的列表 for key in hero_dic: url_hero = "http://lol.qq.com/biz/hero/" + hero_dic[key] + ".js" hero_queue.put(url_hero) img_queue = Queue(1000) # print(hero_queue.get()) save_dir = "F://Downloads//lolskin//" if not os.path.exists(save_dir): os.mkdir(save_dir) for i in range(2): # 这边两个线程就够多了 t = Procuder(hero_queue, img_queue) t.start() for i in range(5): # 对这边的5举行窜改可变换线程数,线程越多载入越快 t = Consumer(hero_queue, img_queue) t.start()if __name__ == '__main__': main()载入后文献:

标签: 英雄联盟皮肤下载

发表评论

大金游戏网Copyright Your WebSite.Some Rights Reserved. 备案号:黑ICP备2021006842号-1