-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrape.js
More file actions
29 lines (22 loc) · 877 Bytes
/
scrape.js
File metadata and controls
29 lines (22 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const { chromium } = require('playwright');
const seeds = [75, 76, 77, 78, 79, 80, 81, 82, 83, 84];
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
let grandTotal = 0;
for (const seed of seeds) {
const url = `https://sanand0.github.io/tdsdata/js_table/?seed=${seed}`;
await page.goto(url, { waitUntil: 'networkidle' });
await page.waitForSelector('table', { timeout: 10000 });
const numbers = await page.$$eval('table td', cells =>
cells
.map(cell => parseFloat(cell.innerText.trim()))
.filter(n => !isNaN(n))
);
const seedTotal = numbers.reduce((a, b) => a + b, 0);
console.log(`Seed ${seed}: ${numbers.length} numbers, sum = ${seedTotal}`);
grandTotal += seedTotal;
}
console.log(`\nGRAND TOTAL (all seeds): ${grandTotal}`);
await browser.close();
})();