Last active
December 22, 2015 04:29
-
-
Save macobo/6417171 to your computer and use it in GitHub Desktop.
Catpickloader
This file contains hidden or 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
| from urllib.request import urlopen | |
| from time import sleep | |
| import json | |
| subreddit = input("sisesta subreddit: ") | |
| url = "http://imgur.com/r/"+subreddit+"/top.json" | |
| vastus = urlopen(url).read().decode("utf8") | |
| andmed = json.loads(vastus) | |
| for pilt in andmed['data']: | |
| nimi = pilt["title"] | |
| print(nimi) | |
| faili_nimi = pilt["hash"] + pilt["ext"] | |
| aadress = "http://i.imgur.com/"+faili_nimi | |
| pildi_andmed = urlopen(aadress).read() | |
| fail = open(faili_nimi, "wb") | |
| fail.write(pildi_andmed) | |
| fail.close() | |
| sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment