1.0.5 • Published 7 years ago

tiny-rebel-web-scraper v1.0.5

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

Tiny Rebel web scraper

A small library for querying available drinks at Tiny Rebel bars

Build Status Build status

Basic usage

npm install tiny-rebel-web-scraper

const tinyRebelWebScraper = require('tiny-rebel-web-scraper');

// Bar location should be specified as "cardiff" or "newport"
tinyRebelWebScraper.getAllDrinks('cardiff')
    .then((drinks) => {
        for (const drink of drinks) {
            console.log(`${drink.name}: ${drink.formattedPrice}`);
        }
    })
    .catch((error) => {
        // Failed to load what drinks are available
        console.error(error);
        throw error;
    });

API

getAllDrinks

Get all drinks at the specified bar.

Method signature

getAllDrinks (barLocation: string): Promise<Drink[]>

getAllKegDrinks

Get all keg drinks at the specified bar.

Method signature

getAllKegDrinks (barLocation: string): Promise<Drink[]>

getAllCaskDrinks

Get all cask drinks at the specified bar.

Method signature

getAllCaskDrinks (barLocation: string): Promise<Drink[]>

Return values

The API will return an array of Drink objects, i.e. POJOs with the following properties.

// Drink
{
    abv: 4.2,
    available: true,
    brewery: 'Tiny Rebel Brewing Co. (Newport, South Wales)',
    cask: true,
    currency: 'GBP',
    formattedAbv: '4.2%',
    formattedPrice: '£3.30',
    keg: false,
    name: 'You Snows It',
    price: 3.3,
    quantity: 'pint',
    style: 'Pale Ale',
    vegan: false
}

Note: Pricing information for drinks will not always be available, in which case the price will be reported as null and the formattedPrice will be reported as 'Unknown'.