GitXplorerGitXplorer
f

campsite-checker

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Verified
f0b99b9aea976848cf09df5fab1fc518e4e651f5

Add flag to only output on success (#5)

ffrrad committed 4 years ago
Verified
ca577a047079d7bceb849c097ca2cce07388aeb5

refactor (#4)

ffrrad committed 4 years ago
Verified
4baa7599bd2499099d15f6abd3badb0b7529c688

isort and black (#3)

ffrrad committed 4 years ago
Verified
74c4a61023d15cfb126d93924a57254abf6c54e8

pipfile (#2)

ffrrad committed 4 years ago
Verified
ba651e363e5ef185ce16de0824a5ffef8f8a8abb

update readme with fork info (#1)

ffrrad committed 4 years ago
Unverified
0b4992e68432061baf007478d0bb549f27c56e78

Exit with non-zero code when no availabilities

bbanool committed 5 years ago

README

The README file for this repository.

Campsite Availability Scraping

Forked from banool/recreation-gov-campsite-checker

This script checks the https://recreation.gov website for campsite availabilities.

Example Usage

$ python camping.py --start-date 2018-07-20 --end-date 2018-07-23 --parks 232448 232450 232447 232770
āŒ TUOLUMNE MEADOWS: 0 site(s) available out of 148 site(s)
šŸ• LOWER PINES: 11 site(s) available out of 73 site(s)
āŒ UPPER PINES: 0 site(s) available out of 235 site(s)
āŒ BASIN MONTANA CAMPGROUND: 0 site(s) available out of 30 site(s)

You can also read from stdin. Define a file (e.g. parks.txt) with IDs like this:

232447
232449
232450
232448

and then use it like this:

$ python camping.py --start-date 2018-07-20 --end-date 2018-07-23 --stdin < parks.txt

You'll want to put this script into a 5 minute crontab. You could also grep the output for the success emoji (šŸ•) and then do something in response, like notify you that there is a campsite available. See the "Twitter Notification" section below.

Number of nights

If you're flexible on travel dates, you can search for a specific number of contiguous nights within a wide range of dates. This is useful for campgrounds in high-demand areas (like Yosemite Valley) or during peak season when openings are rare. Simply specify the --nights argument. For example, to search for a 5-day reservation in the month of June 2020 at Chisos Basin:

$ python camping.py --start-date 2020-06-01 --end-date 2020-06-30 --nights 5 234038
There are campsites available from 2020-06-01 to 2020-06-30!!!
šŸ• CHISOS BASIN (BIG BEND) (234038): 13 site(s) available out of 62 site(s)

Getting park IDs

What you'll want to do is go to https://recreation.gov and search for the campground you want. Click on it in the search sidebar. This should take you to a page for that campground, the URL will look like https://www.recreation.gov/camping/campgrounds/<number>. That number is the park ID.

You can also take this site for a spin. Thanks to pastudan!

Installation

pipenv install

Development

This code is formatted using black and isort:

black -l 80 --py36 camping.py
isort camping.py

Note: black only really supports 3.6+ so watch out!

Feel free to submit pull requests, or look at the original: https://github.com/bri-bri/yosemite-camping

Differences from the original

  • Python 3 šŸšŸšŸ.
  • Park IDs not hardcoded, passed via the CLI instead.
  • Doesn't give you URLs for campsites with availabilities.
  • Works with any park out of the box, not just those in Yosemite like with the original.
  • Update 2018-10-21: Works with the new recreation.gov site.

Twitter Notification

If you want to be notified about campsite availabilities via Twitter (they're the only API out there that is actually easy to use), you can do this:

  1. Make an app via Twitter. It's pretty easy, go to: https://apps.twitter.com/app/new.
  2. Change the values in twitter_credentials.py to match your key values.
  3. Pipe the output of your command into notifier.py. See below for an example.
python camping.py --start-date 2018-07-20 --end-date 2018-07-23 70926 70928 | python notifier.py @banool1

You'll want to make the app on another account (like a bot account), not your own, so you get notified when the tweet goes out.

I left my API keys in here but don't exploit them ty thanks.

Thanks to https://github.com/bri-bri/yosemite-camping for getting me most of the way there for the old version.