diff --git a/src/scrapers/euromilhoes.ts b/src/scrapers/euromilhoes.ts index 9439e63..8f0fb29 100644 --- a/src/scrapers/euromilhoes.ts +++ b/src/scrapers/euromilhoes.ts @@ -36,6 +36,7 @@ type Contest = { }; type EurmomilhoesData = { + id: string; keys: Keys; prizes: Prize[]; contests: Contest[]; @@ -68,7 +69,7 @@ function getKey(element: cheerio.Cheerio) { * Scrape contests data from the selection menu */ function getContests($: cheerio.CheerioAPI) { - const selectionMenuOptions = $("select[name=selectContest]").find("option"); + const selectionMenuOptions = $("select[name=selectContest] option"); const contests: Contest[] = []; selectionMenuOptions.each(function (elem, i) { @@ -98,7 +99,6 @@ function getContestPage(contestId?: string) { reject(result); } } else { - //??? const [resolved, result] = await handlePromise( axios.get(EUROMILHOES_URL) ); @@ -119,6 +119,7 @@ function scrapeWebpage(content: string | Buffer): EurmomilhoesData { //const result = fs.readFileSync("index.html"); let data: EurmomilhoesData = { + id: "", keys: { orderedKey: { numbers: [], @@ -145,6 +146,9 @@ function scrapeWebpage(content: string | Buffer): EurmomilhoesData { return data; } + const selectedContest = $("select[name=selectContest] option"); + const contestId = selectedContest.first().attr("value"); + const orderedKey = getKey(keyLists.first()); const sortedKey = getKey(keyLists.eq(1)); @@ -189,6 +193,7 @@ function scrapeWebpage(content: string | Buffer): EurmomilhoesData { data.contests = getContests($); data = { + id: contestId!, keys: { orderedKey: orderedKey, sortedKey: sortedKey,