Tools to help book fitness classes in the Manchester, UK area.
Main scraping script that downloads fitness class information from the booking website and extracts active class dates.
The script uses a scraper-friendly User-Agent that properly identifies the bot and references this repository, following web scraping best practices.
python3 scrape.pyYou can run this script automatically every 30 minutes on your Android device using Termux. This is useful for continuously monitoring new fitness class availability.
You can use termux-job-scheduler to schedule the script to run every 30 minutes (requires Termux:API app):
-
Install Termux:API:
- Install the Termux:API app from F-Droid
- Install the API package:
pkg install termux-api
-
Run the installation script:
./install_scheduler.sh
This script will automatically:
- Update
run-scraper.shwith the correct repository path - Make the script executable
- Schedule the job to run every 30 minutes
- Update
If you prefer to set up manually:
-
Install Termux:API:
- Install the Termux:API app from F-Droid
- Install the API package:
pkg install termux-api
-
Set up the scheduler script:
The repository includes
run-scraper.shwhich is pre-configured to run the scraper. If you cloned the repository to a different location, edit the script to update the paths:nano run-scraper.sh
Update the paths in the script to match your repository location (replace
~/mcr_fit_sniperwith your actual path). -
Schedule the job to run every 30 minutes:
termux-job-scheduler --script ./run-scraper.sh --period-ms 1800000
Note: 1800000 milliseconds = 30 minutes
To view the output from automated runs (replace ~/mcr_fit_sniper with your repository path):
# View the last 50 lines of the log
tail -n 50 ~/mcr_fit_sniper/scrape.log
# Watch the log in real-time
tail -f ~/mcr_fit_sniper/scrape.logTo view all pending scheduled jobs:
termux-job-scheduler --pendingTo cancel a specific scheduled job:
termux-job-scheduler --cancel --job-id 0Replace 0 with the appropriate job ID from the pending jobs list.
The termux-job-scheduler uses Android's JobScheduler API, which handles scheduling reliably in the background. However:
-
Disable battery optimization for both Termux and Termux:API in Android settings:
- Go to Settings → Apps → Termux → Battery → Unrestricted
- Go to Settings → Apps → Termux:API → Battery → Unrestricted
This ensures the Termux:API app can execute scheduled jobs even when the device is in power-saving mode.
If you're getting a 403 Forbidden error when running scrape.py, we've provided diagnostic tools to help:
-
diagnose_403.py - Automated testing of different header configurations
python3 diagnose_403.py
Tests multiple header combinations to identify what works.
-
capture_headers.py - Capture your browser's headers
python3 capture_headers.py
Then visit
http://localhost:8000for instructions on capturing headers from your working browser. -
TROUBLESHOOTING_403.md - Comprehensive troubleshooting guide
Read this for detailed explanations and step-by-step instructions.
403 errors happen when websites block requests that don't look legitimate. The script uses a scraper-friendly User-Agent (mcr_fit_sniper/1.0 +URL) that properly identifies the bot instead of pretending to be a browser, following web scraping best practices.