Created
August 12, 2022 15:56
-
-
Save Kinetic27/9ed432bc278122feb34f9a8aa6c75002 to your computer and use it in GitHub Desktop.
lol champ downloader python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup as bs | |
import urllib.request | |
import re | |
url = 'https://www.leagueoflegends.com/en-us/champions/' | |
r = requests.get(url) | |
soup = bs(r.text, "html.parser") | |
elements = soup.select('span[class="style__Text-n3ovyt-3 gMLOLF"]') | |
champ_list = [e.text for i, e in enumerate(elements, 1)] | |
for i, champ in enumerate(champ_list): | |
name = ''.join(list(map(lambda n: n[0] + n[1:].lower(), champ.replace("'", "").replace(".", "").split()))) | |
# fxxking exception | |
name = name.replace('JarvanIv', 'JarvanIV') | |
name = name.replace('Kogmaw', 'KogMaw') | |
name = name.replace('Nunu&Willump', 'Nunu') | |
name = name.replace('Reksai', 'RekSai') | |
name = name.replace('RenataGlasc', 'Renata') | |
name = name.replace('Wukong', 'MonkeyKing') | |
down_url = 'https://ddragon.leagueoflegends.com/cdn/img/champion/splash/'+ name + '_0.jpg' | |
print(i, ', download: ' + down_url) | |
urllib.request.urlretrieve(down_url, name + '.jpg') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good job, Gongdol!