Reaperxxxx commited on
Commit
5eba174
·
verified ·
1 Parent(s): ce5241a

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +41 -41
server.js CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
  const express = require("express");
2
  const { chromium } = require("playwright-core");
3
  const cheerio = require("cheerio");
@@ -30,50 +37,43 @@ async function scrapeMatches() {
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
- // Wait a bit after loading to ensure all elements are rendered
36
- await page.waitForTimeout(3000); // Wait for 3 seconds
37
 
38
- // Get all league URLs
39
- const leagueLinks = await page.evaluate(() => {
40
- return Array.from(document.querySelectorAll("select#predregion option"))
41
- .map(option => option.value)
42
- .filter(link => link.includes("/predictions/today/"));
43
- });
44
-
45
- let allMatches = [];
46
-
47
- for (let link of leagueLinks) {
48
- await page.goto(link, { waitUntil: "domcontentloaded", timeout: 60000 });
49
-
50
- // Wait a bit after navigation
51
- await page.waitForTimeout(3000); // Wait for 3 seconds
52
-
53
- const html = await page.content();
54
- const $ = cheerio.load(html);
55
-
56
- $(".wttr").each((_, element) => {
57
- const homeTeam = $(element).find(".wtteam .wtmoblnk").eq(0).text().trim();
58
- const awayTeam = $(element).find(".wtteam .wtmoblnk").eq(1).text().trim();
59
- const stake = $(element).find(".wttd.wtstk").text().trim();
60
- const prediction = $(element).find(".wttd.wtprd").text().trim();
61
- const score = $(element).find(".predscore").text().trim();
62
-
63
- if (homeTeam && awayTeam) {
64
- allMatches.push({
65
- homeTeam,
66
- awayTeam,
67
- stake,
68
- prediction,
69
- score
70
- });
71
- }
72
  });
73
- }
74
 
75
- await browser.close();
76
- return allMatches;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }
78
 
79
  // Express API route
 
1
+ Space each matches like paragraphs but in json
2
+
3
+ {
4
+
5
+
6
+ }
7
+
8
  const express = require("express");
9
  const { chromium } = require("playwright-core");
10
  const cheerio = require("cheerio");
 
37
 
38
  // Navigate to main draw predictions page
39
  const baseURL = "https://www.windrawwin.com/predictions/today/all-games/large-stakes/draws/";
40
+ await page.goto(baseURL, { waitUntil: "domcontentloaded", timeout: 60000 });
 
 
 
41
 
42
+ // Get all league URLs
43
+ const leagueLinks = await page.evaluate(() => {
44
+ return Array.from(document.querySelectorAll("select#predregion option"))
45
+ .map(option => option.value)
46
+ .filter(link => link.includes("/predictions/today/"));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  });
 
48
 
49
+ let allMatches = [];
50
+
51
+ for (let link of leagueLinks) {
52
+ await page.goto(link, { waitUntil: "domcontentloaded", timeout: 60000 });
53
+ const html = await page.content();
54
+ const $ = cheerio.load(html);
55
+
56
+ $(".wttr").each((_, element) => {
57
+ const homeTeam = $(element).find(".wtteam .wtmoblnk").eq(0).text().trim();
58
+ const awayTeam = $(element).find(".wtteam .wtmoblnk").eq(1).text().trim();
59
+ const stake = $(element).find(".wttd.wtstk").text().trim();
60
+ const prediction = $(element).find(".wttd.wtprd").text().trim();
61
+ const score = $(element).find(".predscore").text().trim();
62
+
63
+ if (homeTeam && awayTeam) {
64
+ allMatches.push({
65
+ homeTeam,
66
+ awayTeam,
67
+ stake,
68
+ prediction,
69
+ score
70
+ });
71
+ }
72
+ });
73
+ }
74
+
75
+ await browser.close();
76
+ return allMatches;
77
  }
78
 
79
  // Express API route