"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = exports.crawl = void 0;
const cheerio_1 = require("cheerio");
const lib_1 = require("../lib");
const DOES_NOT_EXIST_MESSAGE = '404 Page Not Found';
const crawl = (word) => {
    return (0, lib_1.request)({
        protocol: 'https',
        hostname: 'www.vajehyab.com',
        path: `/moein/${encodeURIComponent(word)}`,
    });
};
exports.crawl = crawl;
const parse = (html) => {
    const $ = (0, cheerio_1.load)(html);
    const $definitions = $('[itemprop=articleBody]');
    return {
        definitions: Array.from($definitions).map((definition) => $(definition).text()),
        exists: $('#container h1').text() !== DOES_NOT_EXIST_MESSAGE,
    };
};
exports.parse = parse;
