Remove old code && unnecessary @ts-ignore
This commit is contained in:
parent
008e7c1cf4
commit
6dada66079
|
@ -78,7 +78,6 @@ function getDefinitions(term: string) {
|
|||
// TODO: Finish ratings
|
||||
// const upvotes = $(this).find(".thumbs[data-direction=up]").find("span");
|
||||
|
||||
// @ts-ignore
|
||||
const definition = {
|
||||
meaning: meaning,
|
||||
example: example,
|
||||
|
@ -92,8 +91,6 @@ function getDefinitions(term: string) {
|
|||
},
|
||||
};
|
||||
|
||||
//console.log(definition);
|
||||
|
||||
defintions.push(definition);
|
||||
});
|
||||
}
|
||||
|
@ -102,26 +99,4 @@ function getDefinitions(term: string) {
|
|||
});
|
||||
}
|
||||
|
||||
getDefinitions("yogurt");
|
||||
|
||||
export default function scrapeData(url: string) {
|
||||
return new Promise(async function (resolve, reject) {
|
||||
const [success, data] = await handlePromise(axios.get(url));
|
||||
|
||||
if (success) {
|
||||
const html = data.data;
|
||||
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
// For now, only scraping the first/top meaning;
|
||||
|
||||
const meaning = $(".meaning.mb-4").first().text().trim();
|
||||
|
||||
resolve(meaning);
|
||||
} else {
|
||||
console.error(data);
|
||||
|
||||
reject(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
export { getDefinitions };
|
||||
|
|
Loading…
Reference in New Issue