scrabble-solver
Version:
Scrabble Solver 2 - Free, open-source, cross-platform, multi-language analysis tool for Scrabble, Scrabble Duel, Super Scrabble, Letter League, Crossplay, Literaki, and Kelimelik. Quickly find the top-scoring words using the given board and tiles.
27 lines (26 loc) • 918 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = exports.crawl = void 0;
const cheerio_1 = require("cheerio");
const lib_1 = require("../lib");
const crawl = (word) => {
return (0, lib_1.request)({
protocol: 'https',
hostname: 'dexonline.ro',
path: `/definitie/${encodeURIComponent(word)}`,
});
};
exports.crawl = crawl;
const parse = (html) => {
const $ = (0, cheerio_1.load)(html);
const $activeTab = $('.tab-pane.show.active');
$('.type-example').remove();
const $definitions = $activeTab.find('li.type-meaning.depth-0 > .meaningContainer .tree-def.html');
$definitions.find('.meaningTree').remove();
const definitions = Array.from($definitions).map((definition) => $(definition).text().replace(/\n/g, ''));
return {
definitions,
exists: definitions.length > 0,
};
};
exports.parse = parse;