正文
想要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:lol女英雄ps去衣高清图
- 上一篇: 英雄联盟蒙多(英雄联盟蒙多律政大亨)
- 下一篇: 监狱大亨4秘籍_监狱大亨4闪退
猜你喜欢
- 2023-11-141.80千世火龙传奇手游
- 2023-11-031.80天尊复古合击传奇手游
- 2023-10-251.85那年微变九天赋传奇手游
- 2023-10-091.95狗王大怨种超变传奇手游
- 2023-09-281.95九黎八仙超变传奇手游
- 2023-09-191.95天鸿大极品传奇手游
- 最近发表
- 标签列表
-
- 传奇手游 (5)
- 冰雪传奇手游 (3)
- 合击传奇手游 (6)
- 单职业传奇 (11)
- 复古传奇 (42)
- 合击传奇 (107)
- 火龙传奇 (7)
- 合击 (34)
- 沉默 (2)
- 大极品传奇 (8)
- 复古传奇手游 (16)
- 神途手游 (2)
- 1.80火龙 (2)
- 三职业传奇 (85)
- 1.80 (224)
- 1.76 (101)
- 1.85 (58)
- 三职业 (22)
- 火龙 (65)
- 复古 (92)
- 微变 (20)
- 战神 (12)
- 单职业 (5)
- 金币 (13)
- 1.82 (9)
- 微变版本 (2)
- 大极品 (4)
- 复古小极品 (3)
- 微变传奇 (10)
- 战神传奇 (2)
- 变态 (9)
- 1.79 (7)
- 1.95 (47)
- 1.70 (4)
- 小极品传奇 (3)
- 1.78 (3)
- 暗黑 (2)
- 1.80-85 (2)
- 三职业传奇手游 (19)
- 微变传奇手游 (7)
- 火龙传奇手游 (10)
- 迷失传奇手游 (5)
- 无限刀传奇手游 (27)
- 专属传奇手游 (7)
- 单职业传奇手游 (11)
- 宠物传奇手游 (2)
- 金币传奇手游 (2)
- 沉默传奇手游 (3)
- 神器传奇手游 (8)
- 单职业传说手游 (2)