Created
May 13, 2020 13:11
-
-
Save davidkrider/072fb282edde4e003b53c8cbb926b7a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a small script which talks with the Reddit API to do a search | |
| # for a particular phrase. It can be cron'd to run on whatever schedule | |
| # is appropriate. | |
| # In this case, I was trying to find a set of PetSCII key caps for my | |
| # mecahnical keyboard in /r/mechmarket. I've ultimately decided I don't | |
| # want to spend the kind of money it would take to acquire a set, so I've | |
| # stopped caring, but I wanted to save the script for posterity. | |
| # Notably, this relies on the Python praw library to work. | |
| import praw | |
| import os | |
| import re | |
| def notify(title, text): | |
| os.system(""" | |
| osascript -e 'display notification "{}" with title "{}"' | |
| """.format(text, title)) | |
| reddit = praw.Reddit(client_id='XXXXXXXXXXXXXX', | |
| client_secret='XXXXXXXXXXXXXXXXXXXXXXXXXXX', | |
| password='XXXXXXXXXXXXXXXXXXXXXXXX', | |
| user_agent='petscii', | |
| username='YYYYYYYYYYYYYYY') | |
| for submission in reddit.subreddit('mechmarket').new(limit=100): | |
| if re.search("petscii", submission.title, re.I) is not None: | |
| notify("PetSCII?", submission.title) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment