Files
cpubro/debug-benchmark2.js
2025-10-13 08:21:26 +13:00

68 lines
2.1 KiB
JavaScript

const puppeteer = require('puppeteer');
async function debugBenchmark() {
const browser = await puppeteer.launch({
headless: 'new',
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
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');
console.log('Loading CPU benchmark page...');
await page.goto('https://www.cpubenchmark.net/cpu_list.php', {
waitUntil: 'networkidle2',
timeout: 60000
});
console.log('\n=== CHECKING MAIN TABLE ===');
const mainTable = await page.evaluate(() => {
// Find the main data table - it's usually the one with the most rows
const tables = Array.from(document.querySelectorAll('table'));
const mainTable = tables.reduce((largest, table) => {
const rowCount = table.querySelectorAll('tr').length;
const largestCount = largest?.querySelectorAll('tr').length || 0;
return rowCount > largestCount ? table : largest;
});
if (!mainTable) return null;
// Get first row to understand structure
const firstDataRow = mainTable.querySelector('tr:nth-child(2), tbody tr:first-child');
const cells = firstDataRow?.querySelectorAll('td, th');
const firstRowData = cells ? Array.from(cells).map(c => c.textContent.trim()) : [];
// Try to extract data using different methods
const rows = mainTable.querySelectorAll('tr');
const method1 = []; // Using td only
const method2 = []; // Using specific columns
for (let i = 0; i < Math.min(5, rows.length); i++) {
const tds = rows[i].querySelectorAll('td');
if (tds.length >= 2) {
method1.push({
cpu: tds[0]?.textContent?.trim(),
score: tds[1]?.textContent?.trim()
});
}
}
return {
firstRowData,
method1
};
});
console.log('First row data:', mainTable.firstRowData);
console.log('\nMethod 1 (td[0] = name, td[1] = score):');
mainTable.method1.forEach((row, i) => {
console.log(` ${i}: ${row.cpu} = ${row.score}`);
});
await browser.close();
}
debugBenchmark().catch(console.error);