Skip to content

Instantly share code, notes, and snippets.

@Kinetic27
Created August 12, 2022 15:56
Show Gist options
  • Save Kinetic27/9ed432bc278122feb34f9a8aa6c75002 to your computer and use it in GitHub Desktop.
Save Kinetic27/9ed432bc278122feb34f9a8aa6c75002 to your computer and use it in GitHub Desktop.
lol champ downloader python.
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')
@Kinetic27
Copy link
Author

change to public

@justini0715
Copy link

Good job, Gongdol!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment