lol女英雄ps去衣高清图(lol女英雄正能量ps图片二改)

admin 2019-09-28 手游排行榜 105 ℃ 请在这里放置你的在线分享代码
正文

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

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

来点高清图镇楼:

源码私信小编007!

代码如下:

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

下载后文件:

本文TAG:

网站分类
最近发表
标签列表
传奇手游发布网站