A self-hosted website to search and save Reddit user comment history using Python, Streamlit and the Reddit API.
- Tested with Python 3.9
Generate a Reddit API 'client_id' and 'client_secret'
- Click on Create a new app in the Reddit app console: https://www.reddit.com/prefs/apps
- Name the app 'Reddit Comment Search'
- Select 'Script' from the list of radio buttons
- Add the description 'A python script to search through Reddit comment history."
- Use your public IP address as the 'About URL' and the 'Redirect URI'
- Confirm your status as a human
- The client_id will be the short-ish string of random characters underneath the name of the application
- The client_secret will be the "secret" listed under the application when you click on edit application
Once you have your Reddit API details, Update these values in the search.py file:
client_id="XXX"
client_secret="XXX"
Save the search.py file and then use the run.bat file to handle the required dependencies and run the script:
run.bat
The following page will automatically launch in your browser once the dependencies have been installed/checked:
http://localhost:1198/
You can search for a Username, Query the users' comments (blank queries will simply retrieve all comments) and Filter the search for comments made within the last X number of days.
The resulting comments are then individually saved as text files in the 'comments' folder using the filename format:
comment_datestamp - username - query.txt
Open TCP Network Port 1198 to allow communication with Streamlit.
Only one copy of run.bat can be running at a time. If run.bat stalls on launch, open task manager and close down any running intances of python.exe and then try run.bat again.
@GabrielNezovic 2023