Untitled

mail@pastecode.io avatar
unknown
javascript
7 months ago
992 B
7
Indexable
Never
const puppeteer = require('puppeteer');

(async function scrape() {
    const browser = await puppeteer.launch({ headless: false });

    const page = await browser.newPage();
    await page.goto('https://www.betcity.nl/sportsbook#event/1019734458');

    await page.waitForSelector('.KambiBC-betoffer-categories-filter');

    // extracting information from code
    let status = await page.evaluate(() => {
        let statusElement = document.querySelector('.KambiBC-betoffer-categories-filter');
        
        if (statusElement) {
            let onlineElement = statusElement.querySelector('li[data-label="Player Shots on Target"] a');
            
            if (onlineElement) {
                return { online: 'Ja' };
            } else {
                return { online: 'Nee' };
            }
        } else {
            return { online: 'Nee' };
        }
    });

    // logging results
    console.log(status);
    await browser.close();
})();
Leave a Comment