Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import urllib.request
- import os
- import time
- path = "F:/wallpapers/redditautodownload/"
- user_agent = ("Background downloader made by /u/joesv 0.1")
- def download(string):
- r = praw.Reddit(user_agent = user_agent)
- subreddit = r.get_subreddit(string)
- urls = []
- for submission in subreddit.get_hot(limit = 10):
- if "imgur.com" in submission.url:
- urls.append(submission.url)
- print(urls)
- for i in range(0, len(urls)):
- if not ".jpg" in urls[i]:
- urls[i] = urls[i] + ".jpg"
- print(urls[i])
- if not os.path.isfile(urls[i][19:]):
- urllib.request.urlretrieve(urls[i], os.path.join(path + urls[i][19:]))
- while True:
- download("earthporn")
- time.sleep(600)
Add Comment
Please, Sign In to add comment