BACKGROUND // After moving to the Bay Area, I was excited to be so close to Yosemite, which hosts some of the best rock climbing in the world. But what I didn't realized until climbing season came around was that getting a campsite in Yosemite Valley is near impossible. While in the Valley, I talked with a Park Ranger who explained that campsites are released to the reservation website 6 months prior to their reservation date and are filled almost immediately. When people cancel their reservations, it gets kicked back onto the website and becomes available to the public, but is usually picked up again in 15 minutes by someone sitting at their computer hitting refresh on their web browser periodically. But according to the Ranger, this is the best way to try and get a campsite. Of course, as soon as my roommate Drew and I heard this, we thought 'There must be a way to automate the monitoring process so we can know the moment those sites become available...'.
OBJECTIVE // Write a program to monitor the Yosemite Campsite Reservations website to alert me to campsite availabilities when they enter the system.
INGREDIENTS //
……………(1) PHP script
……………(2) Python script
TECHNICAL // The project centered around a PHP script that scraped the websites of each individual campsite to determine when their next available date is. Each individual site has a code that is used to identify it and track which dates have been booked. The website also uses a search function that allows the user to look for the next available date for a specific site. So I compiled a list of all the site codes and then cycled through each of them, requesting the contents of the html page that was produced when the search function was called.
When the contents of each page is returned, I cycle through the verbose, formatting text and search for the phrase 'There are no available dates for this campsite.' If this isn't found, then I know that there is a site available and if I could see the page, they would be listing the next available date. After looking for patterns in how the available dates where formatted across the successful responses, I noticed that the first available date is a clickable link and when you click on the link, it passes the date you clicked through to the booking page. This provided the key phrase that prefaced the date that we needed to extract from the page.
Now, with a list of all the available campsites, we need to determine whether the discovered sites are new since the last time the script sent out an alert, so that we aren't getting an email every minute until a campsite is gone. I had the script save the sites and dates to a text document, so that the next time the script ran, it could cross reference the list and mark only the new dates to be delivered. Once it compiled a list of all the new available reservations, it composed an email from a special GMail account and sent all the new sites/dates with hyperlinks, to me and Drew via email, as well as with a SMS alert.
In order to kick off the PHP script, I wrote a very quick and simple program in Python to request the PHP page and then pause for a minute before repeating. This allows me to only run it when I am looking for a campsite.
RESULT // This turned out to be surprisingly effective. After piloting the php script on Monday, we had a campsite by Tuesday for that Saturday! I was even able to get a coworker a campsite for Memorial Day weekend, just two weeks away!
[ UPDATE ] I stopped using this a couple seasons back and think a very interesting conversation has emerged in this area. I put a fair amount of thought into it when I built the scripts about the ethics of something like this. I, of course, initially looked at the legality of it and as far as I could tell, especially reading the information provided by Recreation.gov below, it didn’t really do anything illegal (would love correction on this if others have better information). I certainly never had any interest in selling campsites or anything like that, just trying to get on some of those mighty fine rocks. Ultimately, the functionality of the script is the same as sitting there and clicking refresh constantly. There’s no purchasing or reserving sites, just notifying me if I am not paying attention, that a site has become available. I’ve certainly received a notification that a campsite is available and had it disappear before I was able to check the website.
I struggled with the ethics element though. I was torn by the idea that my advantage was prohibiting families who are less tech savy from being able to visit Yosemite for the first time. Is it selfish of me to be snatching up campsites to revisit Yosemite while others from around the world would not have a chance to view it for the first time? I have mostly diminished this image in my head since my system only worked on “week of” reservations that have the potential to go unused and likely wouldn’t be useful to anyone but locals like myself.
The other element that concerned me was whether I was contributing to the slippery slope that then artificially morphs the way that our public spaces are available. These places are for everyone to share and you shouldn’t have to know how to code in order to get a campsite there. Am I just helping push things too far and eventually ruining things for everyone? Is it an unfair advantage that I have the skills to work the system like this or is it just applying the countless hours I spent learning to code towards this application instead of using a fraction of those hours to sit there and hit refresh?
Again, I think the conversation here is incredibly interesting and one that I haven’t reached a conclusion on yet. But in the interim, I’ve found myself less comfortable running this script and opting to sleep just outside the park and allowing someone else to grab my spot in the Valley. More thoughts to come but in the meantime, below are a couple interesting articles and threads relating to this conversation:
Can’t get a campsite? It Could be Bots
NOTES // Recreation.gov seemed to be surprisingly open with their data, publishing the following disclaimer on their website:
You are invited to use the data on this website in your publication/website/computer system, and to get updates and refresh your website often via Recreation.gov. We request that you provide credit and a link to Recreation.gov in exchange.
Recreation.gov includes information on Federal government managed and Federal government affiliated (subordinate, subsidiary or member) sites. It does not list hotels, restaurants, or tourist attractions managed by private companies or other organizations. Our content focuses on nature-based, historic and cultural activities commonly available on federally managed lands.
The data in Recreation.gov is provided for free - there is no cost to use it, and no need to contact us before incorporating Recreation.gov data into your system. (In exchange, we encourage you to provide a link to Recreation.gov and acknowledge credit, such as Data Source: Recreation.gov)