It’s no secret that dining at Disneyland can sometimes be as exciting as the rides themselves. Blue Bayou, Lamplight Lounge, and other popular Disneyland restaurants are notoriously tough to get reservations for, often booking up months in advance. But fret not, I used ChatGPT to develop a secret tool for you: a custom Python script that notifies you when a reservation slot opens up!
This script continuously monitors the Disneyland dining reservations website and will notify you via email the moment a reservation becomes available at your desired Disneyland restaurant. It’s like having a personal assistant who never sleeps! Below, I’ll be detailing how you can set up this Python script for yourself.
Let’s get into it!
Step 1: Gather Your Tools
To begin with, you’ll need a couple of tools:
- Python: Ensure you have Python installed on your machine. You can verify this by opening Terminal (or Command Prompt on Windows) and typing
python --version
. If you don’t have Python installed, you can download it from the official Python website. - Beautiful Soup and Requests: These are Python libraries that we will use to parse HTML and send HTTP requests. Install them via pip in the Terminal with the command
pip install beautifulsoup4 requests
. - Terminal or Command Prompt: We’ll be running our Python script from here.
- Google Account: You’ll need a Google account to send email alerts. Ensure you create an App Password for your script to use.
- Text Editor: On Mac, the TextEdit application works well.
Step 2: Monitoring the Network
First, navigate to the Disneyland dining website and click the restaurant you want an alert for. Let’s use Blue Bayou for example. Once you are on the restaurant’s dedicated webpage, click on “Check Availability” and select your desired date, time, and party size to monitor. Do not click “search times” just yet.
Now, right-click on the webpage and select ‘inspect’ to open the Developer Tools, then click on the ‘Network’ tab.
Once you’re on the Network tab, click ‘Search Times’ for your chosen date and time. A new request will appear in the Network panel, similar to this: “https://disneyland.disney.go.com/finder/api/v1/explorer-service/dining-availability/%7BA9464401-62EC-4153-8644-0162EC0153D2%7D/dlr/354099;entityType=restaurant/table-service/2/2023-07-22/?mealPeriod=80000714”
Double-click this request, which will open the link in a new tab. This link is the request your browser sends to check for dining availability, and it’s the URL we’re going to monitor with our Python script.
Step 3: Writing the Python Script
Open your text editor and copy the following Python script into a new file. Make sure to replace the sender_email
, sender_password
, and recipient_email
fields with your own information (I recommend using a Gmail account, which requires you to create an App Password, NOT your regular email password). Next, you need to create an alert name (i.e. “Blue Bayou Alert!”), and copy and paste the disney dining api link from above.
đź”´ Caution! When copying and pasting the script into your text editor, be careful of any changes in the script formatting that might occur, especially with characters like apostrophes and quotation marks. These characters can sometimes be transformed into a format that Python doesn’t understand, leading to errors in your script. If you encounter any syntax errors when running your script, this is one of the first things you should check!
Copy and paste the code below into your text editor app, and replace the red text with your details.
import requests
from bs4 import BeautifulSoup
import smtplib
import time
# Set the URLs of the webpages to scrape and the user-agent string
urls = {
'Insert Alert Name Here': 'Insert availability link here',
}
user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'
# Set the headers to mimic a Chrome browser
headers = {
'User-Agent': user_agent,
'Accept-Language': 'en-US,en;q=0.9',
'Accept-Encoding': 'gzip, deflate, br',
'Upgrade-Insecure-Requests': '1',
'Connection': 'keep-alive',
'Referer': 'https://disneyland.disney.go.com/',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'same-origin',
'Sec-GPC': '1',
}
while True:
for alert_name, url in urls.items():
# Send the HTTP request with the headers
response = requests.get(url, headers=headers)
# Parse the HTML content of the response using BeautifulSoup
soup = BeautifulSoup(response.content, 'html.parser')
# Check if the text "dateTime" is present on the page
if 'dateTime' in soup.get_text():
print(f'Text found for {alert_name}! ({time.strftime("%Y-%m-%d %H:%M:%S")})')
# Set up email details
sender_email = 'Insert your gmail email here'
sender_password = 'Insert your gmail app password here'
recipient_email = 'Insert desired recipient email here'
# Create SMTP server connection
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(sender_email, sender_password)
# Create email message
message = f'Subject: {alert_name} RESERVATION AVAILABLE\n\nThe text "dateTime" was found on the webpage.'
# Send email message
server.sendmail(sender_email, recipient_email, message)
print(f'Email sent for {alert_name}!')
# Close SMTP server connection
server.quit()
else:
print(f'Text not found for {alert_name} ({time.strftime("%Y-%m-%d %H:%M:%S")}).')
# Wait for 60 seconds before checking again
time.sleep(60)
Step 4: Saving and Running the Python Script
Once you have your script ready, it’s time to bring it to life! Here’s how to do it:
Save Your Script
- In TextEdit, navigate to the ‘Format’ menu and select ‘Make Plain Text’.
- Then, navigate to ‘File’ > ‘Save As’.
- Choose a location that’s easily accessible – your desktop, for instance.
- Name your file with the
.py
extension (for example,disney_reservations.py
). This tells your computer that it’s a Python script.
Running Your Script
- Open Terminal (or Command Prompt on Windows).
- Navigate to the directory where you saved your Python script. If you saved it on your desktop, you can do this by typing
cd Desktop
and hitting Enter. - To start running your script, type
python3 disney_reservations.py
(replacedisney_reservations.py
with whatever you named your file) and hit Enter. If your system only has Python 2 installed, you might need to usepython
instead ofpython3
.. Your script should now be running and checking for dining availability every minute.
And voila! You now have your personal dining reservations assistant monitoring for openings at your favorite Disneyland restaurants. As soon as a reservation slot opens up, you’ll receive an email alert.
Remember, be quick to react to the alert because these slots can fill up fast! With this tool at your disposal, your chances of dining at some of Disneyland’s most exclusive restaurants are higher than ever. Have a ‘Beary’ good time dining at Disneyland!
Need Help? Ask ChatGPT!
If you encounter any issues or errors while setting up or running your Python script, remember that you have a powerful tool at your disposal – ChatGPT by OpenAI! ChatGPT can provide solutions to a wide range of Python issues, help debug your script, or even explain complex Python concepts in simple terms. So don’t hesitate to ask ChatGPT for help!