Last active
June 20, 2019 16:16
-
-
Save Gbahdeyboh/3db36152378065ac674cf09d092f12f6 to your computer and use it in GitHub Desktop.
This replicates the clicking issue.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require("puppeteer"); | |
const scraper = { | |
test: async () => { | |
let browser, page; | |
try { | |
browser = await puppeteer.launch({ | |
headless: false, | |
args: ["--no-sandbox", "--disable-setuid-sandbox"] | |
}); | |
page = await browser.newPage(); | |
} catch (err) { | |
console.log(err); | |
} | |
try { | |
await page.goto("https://www.betking.com/sports/s/eventOdds/1-840-841-0-0,1-1107-1108-0-0,1-835-3775-0-0,", { | |
waitUntil: "domcontentloaded" | |
}); | |
console.log("scraping, wait..."); | |
} catch (err) { | |
console.log(err); | |
} | |
console.log("waiting...."); | |
try { | |
await page.waitFor('.eventsWrapper'); | |
} catch (err) { | |
console.log(err, err.response); | |
} | |
try { | |
const divsInRegionAreaContainer = await page.$$('.areaContainer.region .regionGroup > .regionAreas > div:first-child > .area:nth-child(5) div'); | |
const oddsListData = []; | |
for (const div of divsInRegionAreaContainer) { | |
const html = await page.evaluate(el => el.innerHTML, div); | |
if (html === 'GG/NG') { | |
oddsListData.push(html); | |
await div.click(); | |
page.waitFor(1000); | |
} | |
} | |
console.log(oddsListData); | |
} catch (err) { | |
console.log(err); | |
} | |
} | |
} | |
scraper.test(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This logs an array with
[ 'GG/NG', 'GG/NG', 'GG/NG' ]
to the terminal and clicks just the lastGG/NG
div on the page. Scroll down to the last section(the seria A) section to see the clicked element highlighted in orange and the dynamic data already loaded once the process completes.