Skip to content

Instantly share code, notes, and snippets.

@DollarAkshay
Last active May 12, 2020 21:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DollarAkshay/ca65e22c0d08c13df7aed14d53af7c10 to your computer and use it in GitHub Desktop.
Save DollarAkshay/ca65e22c0d08c13df7aed14d53af7c10 to your computer and use it in GitHub Desktop.
Image Scraper in Python
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")
@nicholasyoannou
Copy link

summary: it doesn't work :(

@nithin69
Copy link

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