-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpokescrape.py
35 lines (29 loc) · 1.11 KB
/
pokescrape.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
import urllib.request
import time
import os
def retrieve_pokemon_image(file, url):
cwd = os.getcwd()
fullfilename = os.path.join(cwd,'images', file)
print(fullfilename)
try:
urllib.request.urlretrieve(url, fullfilename)
print("Saved ", file)
except:
print("The attempted pokemon does not exist in Pokemon Assets")
def main():
start_time = time.time()
# Latest Number Available in Pokemon Online
for i in range (1, 906):
file_name = '{:03d}'.format(i) + ".png"
url_string = "https://assets.pokemon.com/assets/cms2/img/pokedex/full/" + file_name
retrieve_pokemon_image(file_name, url_string)
# Number of variations like mega/gigantamax/hisuian
for x in range(2,6):
file_name = '{:03d}'.format(i) + "_f" + str(x) + ".png"
url_string = "https://assets.pokemon.com/assets/cms2/img/pokedex/full/" + file_name
retrieve_pokemon_image(file_name, url_string)
end_time = time.time()
print("Done")
print("Time Duration = ", end_time - start_time, "sec")
if __name__ == "__main__":
main()