|
const puppeteer = require('puppeteer-extra'); |
|
const StealthPlugin = require('puppeteer-extra-plugin-stealth'); |
|
const cheerio = require('cheerio'); |
|
|
|
puppeteer.use(StealthPlugin()); |
|
|
|
(async () => { |
|
const browser = await puppeteer.launch({ headless: true }); |
|
const page = await browser.newPage(); |
|
|
|
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'); |
|
await page.setExtraHTTPHeaders({ |
|
'Accept-Language': 'en-US,en;q=0.9', |
|
'Referer': 'https://www.google.com/' |
|
}); |
|
|
|
await page.setRequestInterception(true); |
|
page.on('request', (req) => { |
|
if (['image', 'stylesheet', 'font'].includes(req.resourceType())) { |
|
req.abort(); |
|
} else { |
|
req.continue(); |
|
} |
|
}); |
|
|
|
await page.goto('https://www.windrawwin.com/predictions/today/all-games/large-stakes/draws/', { |
|
waitUntil: 'domcontentloaded', |
|
timeout: 60000 |
|
}); |
|
|
|
|
|
const leagueLinks = await page.evaluate(() => { |
|
return Array.from(document.querySelectorAll('select#predregion option')) |
|
.map(option => option.value) |
|
.filter(link => link.includes('/predictions/today/')); |
|
}); |
|
|
|
let allMatches = []; |
|
|
|
for (let link of leagueLinks) { |
|
await page.goto(link, { waitUntil: 'domcontentloaded', timeout: 60000 }); |
|
const html = await page.evaluate(() => document.body.innerHTML); |
|
const $ = cheerio.load(html); |
|
|
|
$('.wttr').each((_, element) => { |
|
const homeTeam = $(element).find('.wtteam .wtmoblnk').eq(0).text().trim(); |
|
const awayTeam = $(element).find('.wtteam .wtmoblnk').eq(1).text().trim(); |
|
const stake = $(element).find('.wttd.wtstk').text().trim(); |
|
const prediction = $(element).find('.wttd.wtprd').text().trim(); |
|
const score = $(element).find('.predscore').text().trim(); |
|
|
|
if (homeTeam && awayTeam) { |
|
allMatches.push({ |
|
homeTeam, |
|
awayTeam, |
|
stake, |
|
prediction, |
|
score |
|
}); |
|
} |
|
}); |
|
} |
|
|
|
console.log(allMatches); |
|
await browser.close(); |
|
})(); |