Sid
Rohit Gupta
08/29/2024, 1:22 PMbash
<https://api.pushshift.io/reddit/search/submission/?q=your_keyword&size=10>
### 2. Set Up a Slack Webhook
- Incoming Webhooks: Slack allows you to create incoming webhooks, which are a simple way to send messages to a Slack channel.
- Create a Webhook URL: Set up an incoming webhook in Slack by going to your Slack workspace’s App management page and creating a new app. Once set up, you’ll get a Webhook URL.
### 3. Write a Python Script
- Fetch Data from Pushshift: Use Python’s requests library to fetch data from Pushshift.
- Send Data to Slack: Use the Webhook URL to send the message to your Slack channel.
Example Python script:
python
import requests
# Pushshift API URL
pushshift_url = "<https://api.pushshift.io/reddit/search/submission/?q={}&size=10>"
# Slack Webhook URL
slack_webhook_url = "<https://hooks.slack.com/services/YOUR/WEBHOOK/URL>"
slack_channel = "#your_channel"
# Keywords to search for
keywords = ['keyword1', 'keyword2']
def search_reddit_and_notify():
for keyword in keywords:
response = requests.get(pushshift_url.format(keyword))
data = response.json()
for submission in data['data']:
message = f"Keyword '{keyword}' found: {submission['title']} - {submission['full_link']}"
send_to_slack(message)
def send_to_slack(message):
payload = {"channel": slack_channel, "text": message}
<http://requests.post|requests.post>(slack_webhook_url, json=payload)
# Schedule the script to run periodically
import schedule
import time
schedule.every(10).<http://minutes.do|minutes.do>(search_reddit_and_notify)
while True:
schedule.run_pending()
time.sleep(1)
### 4. Deploy the Script
- Run Locally: Test the script on your local machine.
- Deploy on a Server: Use a VPS, cloud function (like AWS Lambda), or any other service that can run Python scripts at regular intervals.
### 5. Monitor and Maintain
- Logging: Implement basic logging to capture errors or issues.
- Scalability: If you need to scale, consider running the script in parallel or optimizing the search frequency.
### Tools Summary:
- Pushshift API: For retrieving Reddit data without using PRAW.
- Slack Webhook: For sending notifications to Slack.
- Python + Requests Library: For making HTTP requests to Pushshift and Slack.
- Scheduler: To run the script periodically.
This setup allows you to monitor Reddit for specific keywords and receive notifications in Slack without relying on PRAW.Shubham
08/29/2024, 2:58 PMKrishna Goyal
08/30/2024, 8:06 AMRaveesh Motlani
08/31/2024, 11:58 PMPrashant Chaudhary
09/01/2024, 5:54 AM