added puppeteer-extra-plugin-stealth But https://interaktogames.beanstalkedu.com/drawing/?id=27 getting timeout

This commit is contained in:
Kar
2025-03-14 00:54:07 +05:30
parent ea04b813da
commit ab99dad33d
6 changed files with 1955 additions and 108 deletions

View File

@@ -1,9 +1,15 @@
#!/usr/bin/env node
const puppeteer = require('puppeteer');
// const puppeteer = require('puppeteer');
// getting timeout error for https://interaktogames.beanstalkedu.com/drawing/?id=27
const yargs = require('yargs');
const path = require('path');
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer.use(StealthPlugin());
const argv = yargs
.usage('Usage: url-to-image <url> [options]')
.demandCommand(1, 'You need to provide a URL')
@@ -33,10 +39,10 @@ const height = argv.h;
const filename = argv.n || `${Date.now()}.jpg`;
(async () => {
const browser = await puppeteer.launch();
const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();
await page.setViewport({ width, height });
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');
//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');
await page.goto(url, { waitUntil: 'networkidle2', timeout: 60000 });
await page.screenshot({ path: path.resolve(filename) });
await browser.close();