A simple shell script written to scrape gym activity data from the PureGym website members' area.
Works with:
- Windows
- Linux
- OSX
The script logs into the PureGym website using your credentials, scrapes the gym activity from the members' webpage. Then writes the data to a CSV file along with a timestamp. Use the data as it is or import it into a graphing tool to visualise the gym activity trends over time!
It can be scheduled to scrape data at any interval you wish. The following instructions schedule the script to run every 5 minutes.
Important things to note
- You must be a member of PureGym in order to use this script
- When the gym activity is above 100, the website will only display '100+ people' so the script will record it as 100 people.
- Some gyms may pad their numbers. As a result you may see, for example, 20 people being logged in the gym when actually nobody is in the gym at that time.
- The script writes to CSV using Unix line endings.
Clone from GitHub
Clone the project in your terminal by typing:
git clone https://github.com/p-karanthaker/puregym-tracker.git
This will clone it to your current working directory. Change to another directory if you don't want it stored in your current directory.
Execution permissions
The script needs to be executable in order to run.
Use command chmod 744 puregym-tracker.sh
in your terminal to allow execution.
For Windows this will have to be done in your Cygwin terminal.
Manually Running the Script
It is a good idea to manually run the script once before setting up scheduled tasks.
The script can be run manually from the terminal/Cygwin by changing directory to its location and entering
./puregym-tracker.sh LOGIN_EMAIL LOGIN_PIN
.
The script should run with no errors and the CSV file should appear in the logs
directory of the puregym-tracker.
In order to get this working on Windows, there is a little more config required since the tracker is a shell script.
Pre-requisites
- Install Cygwin (ensure Curl is installed in the package selection)
Setting up Task Scheduling
- Import the
PureGymTracker.xml
into Task Scheduler. - If you want it to run when you're not logged in, select the radio button on the window that pops up.
- Go to the
Actions
tab and edit the action listed. - Replace
path\to\run.exe
with its actual path. (Default: C:\cygwinXX\bin\run.exe) whereXX
different based on 32 or 64 bit installs. - In
Add arguments
, replacepath\to\puregym-tracker.sh
with its real path. - Replace
LOGIN_EMAIL
andLOGIN_PIN
with your PureGym login credentials. - Click OK and OK again when you're done. The task will run within the next 5 minutes.
Setting up a CRON job
In your terminal enter crontab -e
. This will open a Vi editor.
Press i
to go into insert mode.
On a new line enter */5 * * * * /path/to/puregym-tracker.sh LOGIN_EMAIL LOGIN_PIN
. Make sure the correct full path is provided.
Press Esc
, then type :wq
followed pressing Enter
to save the file.
The job will run within the next 5 minutes.