Skip to content

Bookings (Web scraper)

Peter Lam edited this page Apr 3, 2021 · 3 revisions

Summary

bookings.py is a tool used to capture the current capacity and popularity of indoor gyms during COVID-19. The goal of bookings.py is to provide insights on local gyms (Altitude Kanata, Altitude Gatineau, Coyote Rock Gym), to help users find the most optimal climbing time according to location, time of day, and time of week. Climbers can utilize this information to make socially responsible decisions. Those looking to minimize their risk whilst still staying active can easily find the off-peak hours of their local gym.

This script collects data to allow for the following visualizations:

  • Busiest time to climb
  • Best time to climb to avoid crowds
  • Average bookings based on gym
  • Popularity across various gyms
  • Bookings overtime

How it works

Using Selenium, bookings.py uses web scraping to open access the reservation systems used by Altitude Kanata, Altitude Gatineau, and Coyote Rock Gym. Although this python tool can gather information manually, it's recommended that users utilize the provide Docker files to automate the process.

Using Docker & docker-compose,bookings.py will automatically run 2 minutes before a reservation time slot begins. Specific run times can be found in the crontab located at climbr/web_scraper/crontab .The following information will then be collected and sent to a local ES database and Google Firestore (if enabled):

booking = {'location': location,
           'month': month.strip(),
           'day_of_week': current_day_of_week,
           'day': day.strip(),
           'year': current_year,
           'time_slot': time.strip(),
           'start_time': start,
           'start_hour': int(common.str_to_time(start).hour),
           'start_minute': int(common.str_to_time(start).minute),
           'end_time': end,
           'availability': availability,
           'reserved_spots': capacity-availability if availability is not None else None,
           'capacity': capacity,
           'zone': zone,
           'retrieved_at': current_time}

Getting Started

Host Requirements

  • Docker 19+
  • Python 3.6+ (Optional)
    • Linux: sudo apt-get install python3 && python3 -m pip install -U pip
    • Windows: Ensure 'Add Python to PATH' is selected

Prerequisites

To allow bookings.py to automatically update visualizations, it's recommended that the docker containers associated with climbr.py are already running (Elasticsearch, Kibana, Climbr CLI).

Clone this wiki locally