Reaperxxxx commited on
Commit
bec2194
·
verified ·
1 Parent(s): 81c46e0

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +13 -9
server.js CHANGED
@@ -28,20 +28,25 @@ async function scrapeMatches() {
28
  : route.continue();
29
  });
30
 
31
- // Navigate to the predictions page
32
  const baseURL = "https://www.windrawwin.com/predictions/today/all-games/large-stakes/draws/";
33
  await page.goto(baseURL, { waitUntil: "domcontentloaded", timeout: 60000 });
34
 
35
- const html = await page.content();
36
- const $ = cheerio.load(html);
 
 
 
 
37
 
38
  let allMatches = [];
39
 
40
- // Extract matches, including competition names
41
- $(".wtcont").each((_, competitionElement) => {
42
- const competitionName = $(competitionElement).find(".ptleag").text().trim();
 
43
 
44
- $(competitionElement).find(".wttr").each((_, element) => {
45
  const homeTeam = $(element).find(".wtteam .wtmoblnk").eq(0).text().trim();
46
  const awayTeam = $(element).find(".wtteam .wtmoblnk").eq(1).text().trim();
47
  const stake = $(element).find(".wttd.wtstk").text().trim();
@@ -50,7 +55,6 @@ async function scrapeMatches() {
50
 
51
  if (homeTeam && awayTeam) {
52
  allMatches.push({
53
- competition: competitionName,
54
  homeTeam,
55
  awayTeam,
56
  stake,
@@ -59,7 +63,7 @@ async function scrapeMatches() {
59
  });
60
  }
61
  });
62
- });
63
 
64
  await browser.close();
65
  return allMatches;
 
28
  : route.continue();
29
  });
30
 
31
+ // Navigate to main draw predictions page
32
  const baseURL = "https://www.windrawwin.com/predictions/today/all-games/large-stakes/draws/";
33
  await page.goto(baseURL, { waitUntil: "domcontentloaded", timeout: 60000 });
34
 
35
+ // Get all league URLs
36
+ const leagueLinks = await page.evaluate(() => {
37
+ return Array.from(document.querySelectorAll("select#predregion option"))
38
+ .map(option => option.value)
39
+ .filter(link => link.includes("/predictions/today/"));
40
+ });
41
 
42
  let allMatches = [];
43
 
44
+ for (let link of leagueLinks) {
45
+ await page.goto(link, { waitUntil: "domcontentloaded", timeout: 60000 });
46
+ const html = await page.content();
47
+ const $ = cheerio.load(html);
48
 
49
+ $(".wttr").each((_, element) => {
50
  const homeTeam = $(element).find(".wtteam .wtmoblnk").eq(0).text().trim();
51
  const awayTeam = $(element).find(".wtteam .wtmoblnk").eq(1).text().trim();
52
  const stake = $(element).find(".wttd.wtstk").text().trim();
 
55
 
56
  if (homeTeam && awayTeam) {
57
  allMatches.push({
 
58
  homeTeam,
59
  awayTeam,
60
  stake,
 
63
  });
64
  }
65
  });
66
+ }
67
 
68
  await browser.close();
69
  return allMatches;