UNPKG

contract-scraper

Version:

A customisable data scraper for the web based on JSON contracts

28 lines (27 loc) 1.13 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const index_1 = __importDefault(require("../../index")); const contract = { itemSelector: '.bloc_annonce_habitat', puppeteer: false, attributes: { name: { type: 'custom-text', selector: '.title_part1' }, description: { type: 'text', selector: '.title_part2' }, size: { type: 'size', selector: '.chiffres_cles span:nth-child(2) strong' }, link: { type: 'link', selector: '.title_part1', attribute: 'href' }, number: { type: 'number', selector: '.prix strong' }, photo: { type: 'link', selector: '.visuel img', attribute: 'src' }, }, }; function customText(inputValue) { return `${inputValue}-custom`; } const scraper = new index_1.default('https://www.blot-immobilier.fr/habitat/achat-location/immobilier/loire-atlantique/nantes/', contract, { 'custom-text': customText, }); scraper.scrapePage().then((data) => { console.log(data); });