-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetRunesImages.py
37 lines (23 loc) · 890 Bytes
/
getRunesImages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import json
import requests
from bs4 import BeautifulSoup
urls = [
'https://u.gg/lol/champions/zac/build',
'https://u.gg/lol/champions/irelia/build',
'https://u.gg/lol/champions/janna/build',
'https://u.gg/lol/champions/rengar/build'
]
runes_dict = {}
for url in urls:
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
rune_trees_container = soup.find('div', class_='rune-trees-container-2 media-query media-query_MOBILE_SMALL__MOBILE_MEDIUM')
images = rune_trees_container.find_all('img')
for img in images:
runa_nome = img.get('alt')
runa_link = img.get('src')
if runa_nome not in runes_dict:
runes_dict[runa_nome] = runa_link
with open('runes.json', 'w') as json_file:
json.dump(runes_dict, json_file, indent=4)
print("Arquivo runes.json salvo com sucesso!")