chore: bump task worker version comment
Force new git SHA to avoid CI scientific notation bug. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
88
backend/scripts/test-treez-capture-text.ts
Normal file
88
backend/scripts/test-treez-capture-text.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import puppeteer from 'puppeteer';
|
||||
import fs from 'fs';
|
||||
|
||||
async function sleep(ms: number): Promise<void> {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const browser = await puppeteer.launch({
|
||||
headless: true,
|
||||
args: ['--no-sandbox', '--disable-setuid-sandbox'],
|
||||
});
|
||||
|
||||
const page = await browser.newPage();
|
||||
await page.setViewport({ width: 1920, height: 1080 });
|
||||
|
||||
// Capture ES API responses as text
|
||||
let allProducts: any[] = [];
|
||||
|
||||
page.on('response', async (res) => {
|
||||
const url = res.url();
|
||||
if (url.includes('gapcommerceapi.com/product/search')) {
|
||||
console.log('ES Response: status=' + res.status());
|
||||
if (res.status() === 200) {
|
||||
try {
|
||||
const text = await res.text();
|
||||
console.log('Response length: ' + text.length);
|
||||
const json = JSON.parse(text);
|
||||
const products = json.hits?.hits?.map((h: any) => h._source) || [];
|
||||
allProducts = allProducts.concat(products);
|
||||
console.log('Got ' + products.length + ' products (total: ' + allProducts.length + ')');
|
||||
} catch (err: any) {
|
||||
console.log('Parse error: ' + err.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Loading page...\n');
|
||||
|
||||
await page.goto('https://shop.bestdispensary.com/shop', {
|
||||
waitUntil: 'networkidle2',
|
||||
timeout: 60000
|
||||
});
|
||||
await sleep(5000);
|
||||
|
||||
// Bypass age gate
|
||||
const ageGate = await page.$('[data-testid="age-gate-modal"]');
|
||||
if (ageGate) {
|
||||
console.log('Bypassing age gate...');
|
||||
const btn = await page.$('[data-testid="age-gate-submit-button"]');
|
||||
if (btn) await btn.click();
|
||||
await sleep(3000);
|
||||
}
|
||||
|
||||
// Wait for initial products to load
|
||||
await sleep(3000);
|
||||
|
||||
console.log('\nInitial products captured: ' + allProducts.length);
|
||||
|
||||
// Try scrolling to trigger more loads
|
||||
console.log('\nScrolling...');
|
||||
for (let i = 0; i < 20; i++) {
|
||||
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
|
||||
await sleep(1500);
|
||||
|
||||
// Also click load more if present
|
||||
try {
|
||||
await page.click('button.collection__load-more');
|
||||
console.log('Clicked load more');
|
||||
} catch {}
|
||||
}
|
||||
|
||||
console.log('\n=== FINAL RESULTS ===\n');
|
||||
console.log('Total products: ' + allProducts.length);
|
||||
|
||||
if (allProducts.length > 0) {
|
||||
console.log('\nFields: ' + Object.keys(allProducts[0]).sort().join(', '));
|
||||
console.log('\nSample:\n' + JSON.stringify(allProducts[0], null, 2));
|
||||
|
||||
fs.writeFileSync('/tmp/treez-products.json', JSON.stringify(allProducts, null, 2));
|
||||
console.log('\nSaved to /tmp/treez-products.json');
|
||||
}
|
||||
|
||||
await browser.close();
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user