Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. import praw
  2. from fnmatch import fnmatch, fnmatchcase
  3.  
  4. domain_filter = ['i.*', 'self.*', 'imgur.*', '*.imgur.*','youtube.*','youtu.*',\
  5.                 'reddit.*', 'gfycat.*', '*.tumblr*']
  6.  
  7. def get_x_posts(n):
  8.     proper_links = 0
  9.     for submission in subreddit.top('day', limit = n):
  10.         if not any(fnmatch(submission.domain, filter) for filter in domain_filter):
  11.             print (submission.domain)
  12.             proper_links = proper_links + 1
  13.             if proper_links < n:
  14.                 get_x_posts(n + 1)
  15.  
  16. rbot = praw.Reddit(user_agent = 'starfoulah2097.tumblr.com',
  17.                     client_id = 'BqC_Qw_OQkFOQA',
  18.                     client_secret = '800XxEW6kQGz4aXMHot5d7vzN6k',
  19.                     username = 'the_reddit_bot',
  20.                     password = 'aqwzsx*')
  21. subreddit = rbot.subreddit(input("Enter a subReddit to scrap : "))
  22. get_x_posts(10)
  23.  
  24. __________________________R E S U L T_____________________________
  25.  
  26. kaliope:~/workspace $ python3 ex50/bin/app.py
  27. Enter a subReddit to scrap : all
  28. reuters.com
  29. reuters.com
  30. reuters.com
  31. reuters.com
  32. reuters.com
  33. reuters.com
  34. reuters.com
  35. reuters.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement