当前位置:网站首页>A few lines of code teach you to crawl lol skin pictures

A few lines of code teach you to crawl lol skin pictures

2022-04-23 18:00:00 Round programmer

Environmental Science win10+ython3.8

import requests
import re
import json

base_url = 'https://game.gtimg.cn/images/lol/act/img/skin/big'
url = 'https://lol.qq.com/biz/hero/champion.js'
respon = requests.get(url=url).text
data = re.search(r'"ID":(.*?),"NAME":',respon).group(1)
data = json.loads(data)
for id,name in data.items():
     for number in range(15):
         iamge_url = base_url +id + '%03d'%number + '.jpg'
         if requests.get(iamge_url).status_code == 200:
             iamge = requests.get(iamge_url).content
             with open('lol/%s%d' % (name,number) + '.jpg','wb') as f:
                 f.write(iamge)

effect
 Insert picture description here

版权声明
本文为[Round programmer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230545315586.html