config: Add 34 files
This commit is contained in:
82
debug-pbtech.js
Normal file
82
debug-pbtech.js
Normal file
@@ -0,0 +1,82 @@
|
||||
const puppeteer = require('puppeteer');
|
||||
|
||||
async function debugPBTech() {
|
||||
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 PB Tech CPU page...');
|
||||
await page.goto('https://www.pbtech.co.nz/category/components/cpus', {
|
||||
waitUntil: 'networkidle2',
|
||||
timeout: 30000
|
||||
});
|
||||
|
||||
console.log('\n=== PAGE TITLE ===');
|
||||
const title = await page.title();
|
||||
console.log(title);
|
||||
|
||||
console.log('\n=== EXTRACTING FIRST FEW PRODUCTS ===');
|
||||
|
||||
const products = await page.evaluate(() => {
|
||||
const results = [];
|
||||
|
||||
// Try to find all possible product containers
|
||||
const selectors = [
|
||||
'.product-item',
|
||||
'.product-card',
|
||||
'[class*="product"]',
|
||||
'.item',
|
||||
'article',
|
||||
'[data-product-id]',
|
||||
'.productbox',
|
||||
'.productcard'
|
||||
];
|
||||
|
||||
for (const selector of selectors) {
|
||||
const elements = document.querySelectorAll(selector);
|
||||
if (elements.length > 0) {
|
||||
results.push({
|
||||
selector: selector,
|
||||
count: elements.length,
|
||||
sample: elements[0]?.outerHTML?.substring(0, 500)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
});
|
||||
|
||||
console.log('\nFound product containers:');
|
||||
products.forEach(p => {
|
||||
console.log(`\nSelector: ${p.selector}`);
|
||||
console.log(`Count: ${p.count}`);
|
||||
console.log(`Sample HTML: ${p.sample}...`);
|
||||
});
|
||||
|
||||
console.log('\n=== EXTRACTING DETAILED PRODUCT INFO ===');
|
||||
|
||||
const detailedInfo = await page.evaluate(() => {
|
||||
// Get first product-like element
|
||||
const product = document.querySelector('.product-item, .product-card, [class*="product"], .productbox, .productcard, article');
|
||||
|
||||
if (!product) return { error: 'No product found' };
|
||||
|
||||
return {
|
||||
outerHTML: product.outerHTML.substring(0, 1500),
|
||||
textContent: product.textContent.substring(0, 500),
|
||||
classes: product.className,
|
||||
id: product.id
|
||||
};
|
||||
});
|
||||
|
||||
console.log('\nFirst product details:');
|
||||
console.log(JSON.stringify(detailedInfo, null, 2));
|
||||
|
||||
await browser.close();
|
||||
}
|
||||
|
||||
debugPBTech().catch(console.error);
|
Reference in New Issue
Block a user