Guest User

Reddit_saved_api

a guest
May 7th, 2018
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 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 = 'VNdvfXhYeJE3EA',
  13.              client_secret = 'd4rIE0sk2I9wo-NKRxarVkFMCKg' ,
  14.              username='Touch_This_Guy',
  15.              password='Saxophone89',
  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
Add Comment
Please, Sign In to add comment