defgetInfo(res): lists=re.findall(r'"keys":(.*?),"data"',res) #print(lists) hero_id=json.loads(lists[0]) #print(hero_id) for hero in hero_id.values(): getSkin(hero)
defgetSkin(hero): url='https://lol.qq.com/biz/hero/'+hero+'.js' try: r=requests.get(url) r.raise_for_status() r.encoding=r.apparent_encoding except: print(url+"爬取失败!") else: html=r.text num=re.findall(r'"id":"(\d{4,6})","num"',html) for i inrange(len(num)): img_url='https://game.gtimg.cn/images/lol/act/img/skin/big' + num[i] + '.jpg' save_img(hero,img_url)