Add stealth mode to browser scraper and Ronis.hr store
- Switch puppeteer to puppeteer-extra with stealth plugin to bypass Cloudflare bot detection - Add Ronis.hr store config (JS-rendered, 48 products per page) - Stealth mode patches navigator.webdriver, chrome runtime, and other fingerprints that Cloudflare checks Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,19 +15,19 @@ function log(msg: string) {
|
||||
async function getBrowser(): Promise<Browser> {
|
||||
if (browser && browser.connected) return browser;
|
||||
|
||||
const puppeteer = await import('puppeteer');
|
||||
const puppeteerExtra = await import('puppeteer-extra');
|
||||
const StealthPlugin = await import('puppeteer-extra-plugin-stealth');
|
||||
puppeteerExtra.default.use(StealthPlugin.default());
|
||||
|
||||
if (config.chromiumWs) {
|
||||
// Connect to remote Chromium (Docker container)
|
||||
log(`Connecting to remote Chromium at ${config.chromiumWs}`);
|
||||
browser = await puppeteer.default.connect({
|
||||
browser = await puppeteerExtra.default.connect({
|
||||
browserWSEndpoint: config.chromiumWs,
|
||||
});
|
||||
log('Connected to remote Chromium');
|
||||
}) as unknown as Browser;
|
||||
log('Connected to remote Chromium (stealth mode)');
|
||||
} else {
|
||||
// Fall back to local launch
|
||||
log('Launching local Chromium...');
|
||||
browser = await puppeteer.default.launch({
|
||||
log('Launching local Chromium (stealth mode)...');
|
||||
browser = await puppeteerExtra.default.launch({
|
||||
headless: true,
|
||||
args: [
|
||||
'--no-sandbox',
|
||||
@@ -37,7 +37,7 @@ async function getBrowser(): Promise<Browser> {
|
||||
'--disable-extensions',
|
||||
'--no-first-run',
|
||||
],
|
||||
});
|
||||
}) as unknown as Browser;
|
||||
log('Local Chromium launched');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user