Reaperxxxx commited on
Commit
ec2a0a7
·
verified ·
1 Parent(s): 89102b5

Create server.js

Browse files
Files changed (1) hide show
  1. server.js +66 -0
server.js ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const puppeteer = require('puppeteer-extra');
2
+ const StealthPlugin = require('puppeteer-extra-plugin-stealth');
3
+ const cheerio = require('cheerio');
4
+
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');
12
+ await page.setExtraHTTPHeaders({
13
+ 'Accept-Language': 'en-US,en;q=0.9',
14
+ 'Referer': 'https://www.google.com/'
15
+ });
16
+
17
+ await page.setRequestInterception(true);
18
+ page.on('request', (req) => {
19
+ if (['image', 'stylesheet', 'font'].includes(req.resourceType())) {
20
+ req.abort();
21
+ } else {
22
+ req.continue();
23
+ }
24
+ });
25
+
26
+ await page.goto('https://www.windrawwin.com/predictions/today/all-games/large-stakes/draws/', {
27
+ waitUntil: 'domcontentloaded',
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
+ })();