UNPKG

afacinemas

Version:

> A web scraper library for [AFA Cinemas](http://www.afacinemas.com.br/)

53 lines 2.23 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TheatersScraper = void 0; const afa_scraper_1 = require("./afa-scraper"); class TheatersScraper extends afa_scraper_1.AfaScraper { constructor() { super(); this.url = `${this.baseUrl}cinemas.php`; } extract() { return __awaiter(this, void 0, void 0, function* () { yield this.loadContent(); const theaters = []; const sections = this.$('section.cartazbreve'); sections.each((_index, element) => { const $element = this.$(element); const id = this.getTheaterId($element); const name = this.getTheaterName($element); const imageLink = this.getImageLink($element); const city = this.getTheaterCity($element); theaters.push({ id, name, imageLink, city }); }); return theaters; }); } getTheaterId(item) { const id = this.$(item).attr('property'); return Number(id); } getTheaterName(item) { const name = this.$(item).attr('title'); return name; } getImageLink(item) { const src = this.$(item).find('img').attr('src'); return `${this.baseUrl}${src}`; } getTheaterCity(item) { const city = this.$(item).find('section.databreve p').last().text().trim(); return city; } } exports.TheatersScraper = TheatersScraper; //# sourceMappingURL=theaters-scraper.js.map