Reaperxxxx commited on
Commit
1c3f302
·
verified ·
1 Parent(s): d3daf77

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +19 -32
server.js CHANGED
@@ -5,7 +5,11 @@ const cheerio = require('cheerio');
5
  puppeteer.use(StealthPlugin());
6
 
7
  (async () => {
8
- const browser = await puppeteer.launch({ headless: true });
 
 
 
 
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
- // Get all leagues
32
- const leagueLinks = await page.evaluate(() => {
33
- return Array.from(document.querySelectorAll('select#predregion option'))
34
- .map(option => option.value)
35
- .filter(link => link.includes('/predictions/today/'));
36
- });
37
-
38
- let allMatches = [];
39
 
40
- for (let link of leagueLinks) {
41
- await page.goto(link, { waitUntil: 'domcontentloaded', timeout: 60000 });
42
- const html = await page.evaluate(() => document.body.innerHTML);
43
- const $ = cheerio.load(html);
 
 
44
 
45
- $('.wttr').each((_, element) => {
46
- const homeTeam = $(element).find('.wtteam .wtmoblnk').eq(0).text().trim();
47
- const awayTeam = $(element).find('.wtteam .wtmoblnk').eq(1).text().trim();
48
- const stake = $(element).find('.wttd.wtstk').text().trim();
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(allMatches);
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
  })();