• Stars
    star
    319
  • Rank 131,491 (Top 3 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Scrapes the recreation.gov website to check for campsite availabilities ๐Ÿ•๐Ÿ•

Campsite Availability Scraping

This has been updated to work with the new recreation.gov site and API!!!

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

Note: Please don't abuse this script. Most folks out there don't know how to run scrapers against websites, so you're at an unfair advantage by using this.

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 park 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

For powershell, try this:

PS > Get-Content parks.txt | python camping.py --start-date 2021-09-24 --end-date 2022-09-24 --stdin

If you want to see more information about which campsites are available, pass --show-campsite-info along with --nights <int>:

$ python camping.py --start-date 2018-07-20 --end-date 2018-07-23 --parks 232448 232450 232447 232770 --show-campsite-info --nights 1 
There are campsites available from 2018-07-20 to 2018-07-23!!!
๐Ÿ• ELK CREEK CAMPGROUND (SAWTOOTH NF) (232042): 1 site(s) available out of 1 site(s)
  * Site 69800 is available on the following dates:
    * 2018-07-20 -> 2018-07-21 
    * 2018-07-21 -> 2018-07-22

If you only want results for certain campsite IDs, pass --campsite-ids <int>:

$ python camping.py --start-date 2018-07-20 --end-date 2018-07-23 --parks 232431 --show-campsite-info --nights 1 --campsite-ids 18621 

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.

Getting campsite IDs

Go to https://recreation.gov and first search for the campground you want and then select the specific campsite within that campground. The URL for the campsite should look like https://www.recreation.gov/camping/campsites/<number>. That number is the campsite ID.

Searching for availability at a specific campsite within a campground

You can search for availability at just a single specific campsite using the '--campsite-ids' argument. This can be useful if you have a favorite campsite you like to use or if you have a reservation at a specific campsite that you want to add days to before or after your existing reservation. This search only works for one campground/campsite combination at a time.

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

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

Installation

I wrote this in Python 3.7 but I've tested it as working with 3.5 and 3.6 also. It is best to use 3.9+

python3 -m venv myvenv
source myvenv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
# You're good to go!

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

Running Tests

All tests should pass before a pull request gets merged. To run all the tests, cd into the project directory and run:

python -m unittest

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.json 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 --parks 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.

More Repositories

1

apue-exercises

Exercises for Advanced Programming in the UNIX Environment (3rd edition)
C
52
star
2

auslan_dictionary

Code for the app, scripts, and site for Auslan Dictionary
Dart
13
star
3

aptos-chess

Play chess on Aptos!
TypeScript
6
star
4

comp30023-assn2

Assignment 2 for COMP30023 - Computer Systems, a game server and client written in C. Running live at mm.dport.me port 12340
C
5
star
5

pycon-au-2018

Code snippets from my Pycon AU 2018 presentation
Python
4
star
6

aptos-infinite-jukebox

Infinite Jukebox, powered by Aptos
Dart
4
star
7

aclip

Bookmarks, powered by Aptos.
Dart
4
star
8

safecycle

1st place project made in less than 24hrs for the Microsoft University of Melbourne Data Science Challenge 2016
CSS
4
star
9

server-setup-old

Finally automate setting up my personal server
Shell
4
star
10

aptos_sdk_dart

Utility for building, signing, and submitting transactions for Aptos in Dart
Dart
4
star
11

trapwords

Online version of Trapwords ๐Ÿ•ต๏ธโ€โ™€๏ธ๐Ÿ•ต๐Ÿผโ€โ™‚๏ธ
JavaScript
4
star
12

aptos-canvas

Canvases on Aptos a la Reddit Place.
TypeScript
3
star
13

aptos-vesting-dashboard

Dashboard with useful vesting / staking / rewards information and utilities.
TypeScript
3
star
14

python-timeline

A little Python timeline with HTML/CSS/JS for recording the history of housemates at my sharehouse.
Python
3
star
15

swen30006-assnC

๐Ÿš– Driving simulation for Software Modelling and Design Assignment Part C ๐Ÿš–
Java
3
star
16

team_heist_tactics

Weeeeeee!!!!!!!!!!!!!!
Rust
3
star
17

move-examples

Move examples.
Move
3
star
18

aptos-tontine

Tontines on Aptos
TypeScript
2
star
19

comp30023-assn1

Assignment 1 for COMP30023 - Computer Systems, a scheduler and memory manager.
C
2
star
20

pycon-au-2019

Code snippets from my Pycon AU 2019 presentation
JavaScript
2
star
21

moondraw

2
star
22

swen30006-assnA

Part A for SWEN30006 - Software Modelling and Design assignment
Java
2
star
23

aptos_api_dart

Aptos API for Dart as generated by the Dart OpenAPI generator.
Dart
2
star
24

amaranta_candles

TypeScript
2
star
25

slsl_dictionary

Sri Lankan Sign Language Dictionary
Dart
2
star
26

comp30020-assn1

Assignment 1 for COMP30020 - Declarative Programming, a card guessing game written in Haskell
HTML
1
star
27

import_times

Prints import times to stderr like 3.7 does, but without having 3.7.
Python
1
star
28

swen30006-assnB

Mailbot 2: Judgement Day
Java
1
star
29

aus-crypto-capital-gains-calculator

Figures out capital gains per coin based on a Coinjar transaction record csv
Rust
1
star
30

vinyl-scrobbler

Listen to vinyl, identify the songs, and scrobble to last.fm
1
star
31

comp30020-assn2

Assignment 2 for COMP30020 - Declarative Programming, a fill-in puzzle solver written in Prolog
Prolog
1
star
32

aptos-move-graphql-test

Demonstrating the Move ABI based GraphQL E2E codegen stack.
TypeScript
1
star
33

telephone

Incorrect bad attempt at doing the loss formula in this paper
Rust
1
star
34

binder

Tools to clean up documents for printing for bookbinding
Jupyter Notebook
1
star
35

dell-monitor-kvm

Tool to switch inputs to Dell UP3017 monitors using their API
C
1
star