メインコンテンツにスキップ

waianapanapa-cabin-availability-checker

🏡 Automated cabin availability checker for Waiʻānapanapa State Park with email notifications

AI Summary

Waianapanapa Cabin Availability Checker

A Google Apps Script library that monitors the Waiʻānapanapa State Park cabin reservation site and notifies you when openings appear.

Target Users

Beginner to intermediate GAS developers who need to automatically watch reservation sites for availability to streamline travel planning.

Problems Solved

Eliminates the tedium of repeatedly refreshing the reservation site and missing rare openings.

Tags

Main Features

1
Automated Periodic Scraping

Uses a time-based trigger to periodically fetch and parse the reservation page for fresh availability data.

2
Instant Email/SMS Alerts

Integrates with Gmail or an external SMS API to instantly alert the user when a vacancy is detected.

3
Serverless & Free Operations

Runs entirely on Google Apps Script so there’s no server to maintain and it operates within Google’s free quota.

Usage Examples

【Introduction】Log availability to console

function checkAvailabilityQuick() {
  // Fetch reservation page HTML
  const url = 'https://dlnr.hawaii.gov/dsp/parks/maui/waianapanapa-state-park/';
  const html = UrlFetchApp.fetch(url).getContentText();
  // Simple keyword test
  const hasVacancy = /Available|Vacancy/i.test(html);
  console.log(`Vacancy? => ${hasVacancy}`);
}

Copy-paste and run – you’ll immediately see whether a vacancy exists.

【Basic】Email when vacancy detected

function checkAndNotify() {
  const url = 'https://dlnr.hawaii.gov/dsp/parks/maui/waianapanapa-state-park/';
  const html = UrlFetchApp.fetch(url).getContentText();
  const hasVacancy = /Available|Vacancy/i.test(html);
  if (hasVacancy) {
    GmailApp.sendEmail(Session.getActiveUser().getEmail(),
      'Waianapanapa cabin open!','A slot just opened:
' + url);
  }
}

Parses the page and shoots an email instantly once a vacancy shows up.

【Best Practice】Stateful check with SMS alert

function checkAndNotifyAdvanced() {
  const url = 'https://dlnr.hawaii.gov/dsp/parks/maui/waianapanapa-state-park/';
  const html = UrlFetchApp.fetch(url).getContentText();

  // Extract individual dates (example regex)
  const dates = [...html.matchAll(/(\d{2}\/\d{2}\/\d{4}).*?(Available)/g)]
                  .map(m => m[1]);
  const props = PropertiesService.getScriptProperties();
  const prev = JSON.parse(props.getProperty('DATES') || '[]');

  // Detect newly available dates
  const newDates = dates.filter(d => !prev.includes(d));
  if (newDates.length) {
    // Send SMS via Twilio webhook
    UrlFetchApp.fetch('https://api.twilio.com/sms', {
      method: 'post',
      payload: {body: `New cabin dates: ${newDates.join(', ')}`}
    });
    // Persist current state
    props.setProperty('DATES', JSON.stringify(dates));
  }
}

Stores the last result in PropertiesService and fires an SMS (via Twilio) only when new dates appear.