Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- from fnmatch import fnmatch, fnmatchcase
- domain_filter = ['i.*', 'self.*', 'imgur.*', '*.imgur.*','youtube.*','youtu.*',\
- 'reddit.*', 'gfycat.*', '*.tumblr*']
- def get_x_posts(n):
- proper_links = 0
- for submission in subreddit.top('day', limit = n):
- if not any(fnmatch(submission.domain, filter) for filter in domain_filter):
- print (submission.domain)
- proper_links = proper_links + 1
- if proper_links < n:
- get_x_posts(n + 1)
- rbot = praw.Reddit(user_agent = 'starfoulah2097.tumblr.com',
- client_id = 'BqC_Qw_OQkFOQA',
- client_secret = '800XxEW6kQGz4aXMHot5d7vzN6k',
- username = 'the_reddit_bot',
- password = 'aqwzsx*')
- subreddit = rbot.subreddit(input("Enter a subReddit to scrap : "))
- get_x_posts(10)
- __________________________R E S U L T_____________________________
- kaliope:~/workspace $ python3 ex50/bin/app.py
- Enter a subReddit to scrap : all
- reuters.com
- reuters.com
- reuters.com
- reuters.com
- reuters.com
- reuters.com
- reuters.com
- reuters.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement