1.2.16 • Published 1 year ago

get-booking-prices v1.2.16

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

get-booking-prices

Tiny library to retrieve booking data (rooms with their prices) from Booking.com.

Requires node version >= 18 (uses new native fetch to make http requests)

Uses cheerio.js to parse data from HTML data.

Installation

yarn add get-booking-prices

Usage (React)

import { getRooms } from "get-booking-prices";
import * as React from "react";

export default function App() {
  const [rooms, setRooms] = React.useState([]);

  React.useEffect(() => {
    const getData = async () => {
      try {
        const hotelSlug = "zarzuela"; // Get the hotel slug from Booking.com url details page
        const checkin = new Date();
        const checkout = new Date();
        checkout.setDate(checkout.getDate() + 1);
        const options = { 
          adults: 2, // Optional. Default: 2
          country: 'br', // Optional. Default: br (hotel country)
        };
        const rooms = await getRooms(hotelSlug, checkin, checkout, options);
        setRooms(rooms);
        console.log(`Rooms:`, rooms);
      } catch (e) {
        console.error(e);
      }
    };

    getData();
  }, []);

  return (
    <div>
      <span>Rooms availability: {rooms.length}</span>
    </div>
  );
}
1.2.16

1 year ago

1.2.15

1 year ago

1.2.14

1 year ago

1.2.13

1 year ago

1.2.12

1 year ago

1.2.11

1 year ago

1.2.10

1 year ago

1.2.9

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.0

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.0

1 year ago