mburton2

RedditSaveDone

Jun 2nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. import praw
  2. import os
  3. import urllib
  4. from praw.models import Submission
  5. from StringIO import StringIO
  6. from PIL import Image
  7.  
  8. Ifolder = open('C:\Users\mickey b\Pyfiles\RedditImage', 'w')
  9. _image_formats = ['.bmp','.gif','.jpg','.jpeg','.png']
  10.  
  11.  
  12. r = praw.Reddit(client_id = '*************',
  13.              client_secret = '*****************' ,
  14.              username='*********',
  15.              password='***********',
  16.              user_agent='prawtutorial')
  17. saved = r.user.me().saved(limit=None)
  18.  
  19. count = 0
  20. for item in saved:
  21.     for xx in _image_formats:
  22.         new_list = [xx]
  23.     if isinstance(item, Submission):
  24.         if item.url.endswith(tuple(_image_formats)):                  
  25.             jj = Image.open(StringIO(urllib.urlopen(item.url).read()))        
  26.             jj.save('C:\Users\Mickey B\pyfiles\Redditimages\\'+str(count)+ ' '+ str(item)+ xx)
  27.             count += 1
  28.         else:
  29.             pass
Add Comment
Please, Sign In to add comment