Update server.js
Browse files
server.js
CHANGED
|
@@ -30,45 +30,51 @@ 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 |
-
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
return Array.from(document.querySelectorAll("select#predregion option"))
|
| 38 |
-
.map(option => option.value)
|
| 39 |
-
.filter(link => link.includes("/predictions/today/"));
|
| 40 |
-
});
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
const prediction = $(element).find(".wttd.wtprd").text().trim();
|
| 54 |
-
const score = $(element).find(".predscore").text().trim();
|
| 55 |
-
|
| 56 |
-
if (homeTeam && awayTeam) {
|
| 57 |
-
allMatches.push({
|
| 58 |
-
homeTeam,
|
| 59 |
-
awayTeam,
|
| 60 |
-
stake,
|
| 61 |
-
prediction,
|
| 62 |
-
score
|
| 63 |
-
});
|
| 64 |
-
}
|
| 65 |
-
});
|
| 66 |
-
}
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
}
|
| 71 |
|
|
|
|
|
|
|
|
|
|
| 72 |
// Express API route
|
| 73 |
app.get("/draw", async (req, res) => {
|
| 74 |
try {
|
|
|
|
| 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 an extra 3 seconds after loading
|
| 36 |
+
await page.waitForTimeout(3000);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 an extra 3 seconds after loading
|
| 51 |
+
await page.waitForTimeout(3000);
|
| 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 |
// Express API route
|
| 79 |
app.get("/draw", async (req, res) => {
|
| 80 |
try {
|