EM numbers

by Geoffrey Gazet

HTML

<table id="table" border="0" cellpadding="0" cellspacing="0" class="lp4" align="center" width="100%"><tbody>
<tr align="center" class="trd"><td>Date du tirage</td>
<td>Combinaison gagnante</td>
<td>Montant du jackpot</td>
</tr><tr align="center" class="ligne1"><td class="tdc"><a href="/euromillions/resultat/tirage1610_Vendredi-24-fevrier-2023.html" title="Tirage Euro Millions N° 1610 du 24 Février 2023">24/02/2023</a></td>
<td class="tdi"><table border="0" align="center" cellpadding="0" cellspacing="0" class="tresupf"><tbody><tr align="center" valign="middle"><td width="30" height="36" class="tdnum">7</td><td width="30" height="36" class="tdnum">23</td><td width="30" height="36" class="tdnum">34</td><td width="30" height="36" class="tdnum">42</td><td width="30" height="36" class="tdnum">48</td><td width="34" height="36" class="tdeto">1</td><td width="34" height="36" class="tdeto">3</td></tr></tbody></table></td>
<td class="tdg"><table><tbody><tr><td class="tdno"><img src="/i/v3barmoins.gif" width="89" height="15" alt="" border="0"></td><td class="tdno">102.242.065&nbsp;€</td></tr></tbody></table></td>
</tr><tr align="center" class="ligne1"><td class="tdc"><a href="/euromillions/resultat/tirage1609_Mardi-21-fevrier-2023.html" title="Tirage Euro Millions N° 1609 du 21 Février 2023">21/02/2023</a></td>
<td class="tdi"><table border="0" align="center" cellpadding="0" cellspacing="0" class="tresupf"><tbody><tr align="center" valign="middle"><td width="30" height="36" class="tdnum">21</td><td width="30" height="36" class="tdnum">22</td><td width="30" height="36" class="tdnum">34</td><td width="30" height="36" class="tdnum">41</td><td width="30" height="36" class="tdnum">49</td><td width="34" height="36" class="tdeto">2</td><td width="34" height="36" class="tdeto">7</td></tr></tbody></table></td>
<td class="tdg"><table><tbody><tr><td class="tdno"><img src="/i/v3barmoins.gif" width="76" height="15" alt="" border="0"></td><td...

JavaScript

var website = "https://www.loterieplus.com/euromillions/resultat/derniers-resultats.php";

var rows = document.getElementById("table").rows;

const nums = new Array(50).fill(0);
const complementary = new Array(12).fill(0);

for( var i = 0; i < rows.length; i++) {
    const row = rows[i];
    const numbers = row.cells[1]?.firstChild;
    if (numbers && numbers.firstChild) {
		    let countNum = 0;
        for (let cell of numbers.firstChild.firstChild.cells) {
            if (countNum <= 4) {
               nums[Number(cell.innerHTML) - 1] = nums[Number(cell.innerHTML) - 1] + 1;
               countNum++;	
            } else {
              complementary[Number(cell.innerHTML) - 1] = complementary[Number(cell.innerHTML) - 1] + 1;
            }
				}
    }
}

const countPerNumbers = nums.map((num, i) => ({
	number: i + 1,
	count: num
})).sort((a, b) => a.count < b.count ? 1 : -1);

const countPerCompl = complementary.map((num, i) => ({
	number: i + 1,
	count: num
})).sort((a, b) => a.count < b.count ? 1 : -1);


console.log(countPerNumbers, countPerCompl);