Last active
May 12, 2020 21:54
-
-
Save DollarAkshay/ca65e22c0d08c13df7aed14d53af7c10 to your computer and use it in GitHub Desktop.
Image Scraper in 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 cv2 | |
import numpy as np | |
import urllib.request | |
import time | |
start_time = time.time() | |
for i in range(1, 51): | |
try: | |
req = urllib.request.Request( | |
'https://assets.pokemon.com/assets/cms2/img/pokedex/detail/' + '{:03d}'.format(i) + '.png') | |
response = urllib.request.urlopen(req) | |
rr = response.read() | |
ba = bytearray(rr) | |
image = np.asarray(ba, dtype="uint8") | |
image = cv2.imdecode(image, cv2.IMREAD_UNCHANGED) | |
cv2.imwrite("data/gg/" + '{:04d}'.format(i) + ".png", image) | |
print("Saved " + '{:04d}'.format(i) + ".png") | |
except Exception as e: | |
print("Error Occured for Pokemon " + '{:04d}'.format(i)) | |
print(str(e)) | |
end_time = time.time() | |
print("Done") | |
print("Time Taken = ", end_time - start_time, "sec") |
summary: it doesn't work :(
remove "gg/" in imwrite or add "gg" folder in your data folder
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
summary: it doesn't work :(