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>
105 lines
2.9 KiB
TypeScript
105 lines
2.9 KiB
TypeScript
import puppeteer from 'puppeteer';
|
|
|
|
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 all network requests
|
|
const requests: any[] = [];
|
|
const responses: any[] = [];
|
|
|
|
page.on('request', (req) => {
|
|
const url = req.url();
|
|
if (url.includes('api') || url.includes('graphql') ||
|
|
url.includes('product') || url.includes('menu') ||
|
|
url.includes('treez') || url.includes('inventory')) {
|
|
requests.push({
|
|
url: url.slice(0, 150),
|
|
method: req.method(),
|
|
headers: req.headers(),
|
|
postData: req.postData()?.slice(0, 500),
|
|
});
|
|
}
|
|
});
|
|
|
|
page.on('response', async (res) => {
|
|
const url = res.url();
|
|
if (url.includes('api') || url.includes('graphql') ||
|
|
url.includes('product') || url.includes('menu') ||
|
|
url.includes('inventory')) {
|
|
try {
|
|
const contentType = res.headers()['content-type'] || '';
|
|
if (contentType.includes('json')) {
|
|
const body = await res.text();
|
|
responses.push({
|
|
url: url.slice(0, 150),
|
|
status: res.status(),
|
|
bodyPreview: body.slice(0, 1000),
|
|
});
|
|
}
|
|
} catch {}
|
|
}
|
|
});
|
|
|
|
console.log('Loading page and capturing network requests...\n');
|
|
|
|
await page.goto('https://shop.bestdispensary.com/brands', {
|
|
waitUntil: 'networkidle2',
|
|
timeout: 60000
|
|
});
|
|
await sleep(3000);
|
|
|
|
// Bypass age gate
|
|
const ageGate = await page.$('[data-testid="age-gate-modal"]');
|
|
if (ageGate) {
|
|
const btn = await page.$('[data-testid="age-gate-submit-button"]');
|
|
if (btn) await btn.click();
|
|
await sleep(2000);
|
|
}
|
|
|
|
// Click load more to trigger more API calls
|
|
for (let i = 0; i < 3; i++) {
|
|
const btn = await page.$('button.collection__load-more');
|
|
if (btn) {
|
|
await btn.click();
|
|
await sleep(2000);
|
|
}
|
|
}
|
|
|
|
// Also visit a product page
|
|
console.log('\nVisiting a product page...\n');
|
|
await page.goto('https://shop.bestdispensary.com/product/dime-sour-grapes-2g-disposable-cartridge-2-grams', {
|
|
waitUntil: 'networkidle2',
|
|
timeout: 30000
|
|
});
|
|
await sleep(2000);
|
|
|
|
console.log('=== API REQUESTS FOUND ===\n');
|
|
requests.forEach((r, i) => {
|
|
console.log((i+1) + '. ' + r.method + ' ' + r.url);
|
|
if (r.postData) {
|
|
console.log(' POST data: ' + r.postData);
|
|
}
|
|
});
|
|
|
|
console.log('\n=== JSON RESPONSES ===\n');
|
|
responses.forEach((r, i) => {
|
|
console.log((i+1) + '. ' + r.url);
|
|
console.log(' Status: ' + r.status);
|
|
console.log(' Body: ' + r.bodyPreview.slice(0, 300) + '...\n');
|
|
});
|
|
|
|
await browser.close();
|
|
}
|
|
|
|
main().catch(console.error);
|