Update server.js
Browse files
server.js
CHANGED
|
@@ -5,7 +5,11 @@ const cheerio = require('cheerio');
|
|
| 5 |
puppeteer.use(StealthPlugin());
|
| 6 |
|
| 7 |
(async () => {
|
| 8 |
-
const browser = await puppeteer.launch({
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
const page = await browser.newPage();
|
| 10 |
|
| 11 |
await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36');
|
|
@@ -28,39 +32,22 @@ puppeteer.use(StealthPlugin());
|
|
| 28 |
timeout: 60000
|
| 29 |
});
|
| 30 |
|
| 31 |
-
|
| 32 |
-
const
|
| 33 |
-
|
| 34 |
-
.map(option => option.value)
|
| 35 |
-
.filter(link => link.includes('/predictions/today/'));
|
| 36 |
-
});
|
| 37 |
-
|
| 38 |
-
let allMatches = [];
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
const
|
| 43 |
-
const
|
|
|
|
|
|
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
const prediction = $(element).find('.wttd.wtprd').text().trim();
|
| 50 |
-
const score = $(element).find('.predscore').text().trim();
|
| 51 |
-
|
| 52 |
-
if (homeTeam && awayTeam) {
|
| 53 |
-
allMatches.push({
|
| 54 |
-
homeTeam,
|
| 55 |
-
awayTeam,
|
| 56 |
-
stake,
|
| 57 |
-
prediction,
|
| 58 |
-
score
|
| 59 |
-
});
|
| 60 |
-
}
|
| 61 |
-
});
|
| 62 |
-
}
|
| 63 |
|
| 64 |
-
console.log(
|
| 65 |
await browser.close();
|
| 66 |
})();
|
|
|
|
| 5 |
puppeteer.use(StealthPlugin());
|
| 6 |
|
| 7 |
(async () => {
|
| 8 |
+
const browser = await puppeteer.launch({
|
| 9 |
+
headless: true,
|
| 10 |
+
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
| 11 |
+
});
|
| 12 |
+
|
| 13 |
const page = await browser.newPage();
|
| 14 |
|
| 15 |
await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36');
|
|
|
|
| 32 |
timeout: 60000
|
| 33 |
});
|
| 34 |
|
| 35 |
+
const html = await page.evaluate(() => document.body.innerHTML);
|
| 36 |
+
const $ = cheerio.load(html);
|
| 37 |
+
let matches = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
$('.wttr').each((_, element) => {
|
| 40 |
+
const homeTeam = $(element).find('.wtteam .wtmoblnk').eq(0).text().trim();
|
| 41 |
+
const awayTeam = $(element).find('.wtteam .wtmoblnk').eq(1).text().trim();
|
| 42 |
+
const stake = $(element).find('.wttd.wtstk').text().trim();
|
| 43 |
+
const prediction = $(element).find('.wttd.wtprd').text().trim();
|
| 44 |
+
const score = $(element).find('.predscore').text().trim();
|
| 45 |
|
| 46 |
+
if (homeTeam && awayTeam) {
|
| 47 |
+
matches.push({ homeTeam, awayTeam, stake, prediction, score });
|
| 48 |
+
}
|
| 49 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
console.log(matches);
|
| 52 |
await browser.close();
|
| 53 |
})();
|