This Python script checks for campsite availability on recreation.gov and sends notifications when a site is available for specified dates.
- Checks campsite availability for specified campgrounds and dates.
- Sends notifications via ntfy when a site is available.
- Configurable request headers and API URL.
- Python 3.x
requests
library
- Clone the repository:
git clone https://github.com/Teachmetech/campsite.git
cd campsite
- Install the required packages:
pip install -r requirements.txt
- Define your campgrounds and dates in the script.
camp_grounds = {
"Campground A": "123456",
"Campground B": "789012"
}
dates = [
("2024-06-01", "2024-06-05"),
("2024-07-10", "2024-07-15")
]
- Create an instance of the
Campsite
class and call thecheck_sites
method.
campsite_checker = Campsite(camp_grounds, dates)
campsite_checker.check_sites()
recreation_api_url
: URL to fetch campsite availability (default provided).request_headers
: Headers for the HTTP requests (default provided).ntfy_url
: URL for the ntfy notification service (default:https://ntfy.sh
).ntfy_topic
: Topic for ntfy notifications (default:campsite
).infinite_run
: Keep checking until the program is stopped (default: True).sleep_time
: Time in seconds to wait between checks (default: 60).debug
: Print debug info (default: False).
import time
import requests
from datetime import datetime, timedelta
# camp_grounds keys can be anything, this is what NTFY will use in its message
# For example, you could use Camp Cook Campsite or camp_cook_campsite for the key
# The value matters, however, as this is the ID of the campsite which you can find
# in the URL when clicking on the campsite. -->
camp_grounds = {
"Campground A": "123456",
"Campground B": "789012"
}
dates = [
("2024-06-01", "2024-06-05"),
("2024-07-10", "2024-07-15")
]
campsite_checker = Campsite(camp_grounds, dates)
campsite_checker.check_sites()
This project is licensed under the MIT License.