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.
23 lines (18 loc) • 588 B
text/typescript
import { load } from 'cheerio';
import { request } from '../lib';
import type { ParsingResult } from '../types';
export const crawl = (word: string): Promise<string> => {
return request({
protocol: 'https',
hostname: 'www.cnrtl.fr',
path: `/definition/${encodeURIComponent(word)}`,
});
};
export const parse = (html: string): ParsingResult => {
const $ = load(html);
const $definitions = $('.tlf_cdefinition');
return {
definitions: Array.from($definitions).map((definition) => $(definition).text()),
exists: $('#vitemselected span').length > 0,
};
};