Advertisement
chluebi

Untitled

Sep 1st, 2018
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. import praw
  2. import discord
  3. import urllib
  4.  
  5. reddit = praw.Reddit(client_id = 'id',
  6.                      client_secret = 'secret',
  7.                      username = 'user',
  8.                      password = 'pw',
  9.                      user_agent = 'agent')
  10.  
  11.  
  12. client = discord.Client()
  13.  
  14. subred = reddit.subreddit('cutetraps').top(limit=10000)
  15. i = 0
  16.  
  17. for submission in subred:
  18.     if not (submission.over_18 or len(submission.url) > 40):
  19.  
  20.         pic = submission.url
  21.         print(submission.url)
  22.         if pic.endswith('.jpg'):
  23.             resource = urllib.request.urlopen(pic)
  24.             output = open("pic{}.jpg".format(i), "wb+")
  25.             output.write(resource.read())
  26.             output.close()
  27.             i += 1
  28.         if pic.endswith('.png'):
  29.             resource = urllib.request.urlopen(pic)
  30.             output = open("pic{}.png".format(i), "wb+")
  31.             output.write(resource.read())
  32.             output.close()
  33.             i += 1
  34.     else:
  35.         print('nope')
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. client.run('token')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement