UNPKG

@benbakhar/sls

Version:

Nike SLS API

32 lines (31 loc) 1.2 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const cheerio_1 = __importDefault(require("cheerio")); const fetch_page_1 = __importDefault(require("../../shared/fetch-page")); const PAGE_URL = "http://streetleague.com/tickets"; const parsePage = (html) => { const locations = []; const year = +cheerio_1.default("#content .container .page-title-heading", html).text().replace(/\D/g, ""); cheerio_1.default("#content #event-items li", html).map((_, eventItem) => { const location = cheerio_1.default(eventItem).find(".event-title h4 a").text(); const venue = cheerio_1.default(eventItem).find(".event-venue").text(); const date = cheerio_1.default(eventItem).find(".event-date span").slice(0, 1).text(); locations.push({ date, location, venue, }); }); return { locations, year, }; }; async function get() { const html = await fetch_page_1.default(PAGE_URL); return parsePage(html); } exports.get = get;