Instructions • Getting Started • Online Users • Future Features
Track the amount of online users for a given subreddit you provide every time interval, and save that data to display on a graph.
1.) Download the zip file and extract the contents.
2.) Open the active_user_bot.py module
First, you'll want to set up your credentials to use the Reddit API. At the the bottom of active_user_bot.py you will notice:
bot = OnlineUserBot('SUBREDDIT_NAME', INTERVAL, TOTAL_TIME, 'CLIENT_ID','CLIENT_SECRET','PASSWORD','USER_AGENT','USERNAME')
You can watch this video made by Sentdex to help you set this up! https://www.youtube.com/watch?v=NRgfgtzIhBQ
Once you've set up your credentials, you need to change 3 more things.
- SUBREDDIT_NAME
- Should be in the form of whatever comes after the r/. For example r/gatech should become gatech.
- This is case sensitive, so be careful!
- type = str. Keep the parentheses
- INTERVAL
- This is the number of seconds between each call to the api for data. I find that about 10-30 seconds is good because the number of users only updates about every 20-30 seconds.
- The type must be just an integer
- TOTAL_TIME
- This is the total time in seconds that you want the program to run.
- The type must also be an integer
Once this is done, you are all set. As long as the dependencies are installed, you should be able to run it just nicely.
This script will collect the online user count of the given subreddit you provide, and store the data in a csv file. You will notice it'll create file in this directory titled data.csv
In this file you will see data in the form of
248,21-33-03
249,21-33-14
249,21-33-24
249,21-33-35
It includes the time that the data was collected at, and the online user count at that time.
active_user_bot.py
praw
time
csv
datetime
matplotlib.pyplot
* Predict the best time to post something for maximum view potential. * Two separate files, one for graphing and one for api calling. * Really anything that can make it better, I will try to do. I am open to any suggestions if you would like to help me.
- r/gatech
- r/python
- https://github.com/TinyQubit/RedditBot_OnlineUsers - For .md help and how to format graph. Litaraly coded the whole thing by myself and then searched to see if someone else had done won and walah, one ten times better than mine.