Quick Answer: Web Automation with Puppeteer#
4 Production Use Cases for Puppeteer Automation#
At Rajput Bhavin Engineering, we build custom web automation and scraping engines across several high-impact business workflows:
┌─────────────────────────────────────────────────────────────┐
│ Puppeteer Production Use Cases │
├─────────────────────┬───────────────────────────────────────┤
│ Dynamic Scraping │ Extracting data from JS-rendered SPAs │
│ Automated PDF Gen │ Generating pixel-perfect PDF invoices │
│ Synthetic E2E Tests │ Simulating multi-step user checkouts │
│ Bot Task Execution │ Submitting compliance forms & portals │
└─────────────────────┴───────────────────────────────────────┘
1. High-Performance SPA Scraping with Stealth#
Modern websites load data asynchronously via internal API calls and client-side JavaScript. Traditional HTML parsers (like Cheerio or BeautifulSoup) receive an empty Generate formatted invoices, audit certificates, or analytics summaries using raw HTML and CSS print stylesheets: Need automated web scrapers, data extraction pipelines, or headless browser workflows engineered for your enterprise? Rajput Bhavin Engineering builds custom AI-powered automation systems, web scrapers, workflow bots, and real-time data pipelines for enterprises across industries. Founder and Systems Architect at Rajput Bhavin Engineering in Gota, Ahmedabad. Specializes in high-concurrency cloud software, Next.js web applications, multi-tenant SaaS architecture, and autonomous AI systems. A practical software engineering guide on writing maintainable, self-documenting code. Master the 5 SOLID principles with real-world TypeScript before-and-after refactoring examples. Looking for custom enterprise software development? Rajput Bhavin Engineering designs scalable microservices, bespoke ERP/CRM platforms, and high-concurrency cloud architectures for modern enterprises. A complete software engineering guide on Docker containerization for full-stack web applications. Learn multi-stage build optimization, non-root security, Docker Compose networks, and layer caching.#Production Stealth Scraping Script:
import puppeteer from 'puppeteer-extra';
import StealthPlugin from 'puppeteer-extra-plugin-stealth';
// Apply stealth plugin to bypass Cloudflare / Bot detection fingerprints
puppeteer.use(StealthPlugin());
export async function scrapeCompetitorPricing(targetUrl: string) {
const browser = await puppeteer.launch({
headless: true,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage', // Prevents memory crashes in Docker
'--disable-accelerated-2d-canvas',
'--disable-gpu',
],
});
const page = await browser.newPage();
// Set realistic viewport & user agent
await page.setViewport({ width: 1920, height: 1080 });
await page.setUserAgent(
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36'
);
// Block unnecessary assets (images, stylesheets, fonts) to accelerate scraping by 4x
await page.setRequestInterception(true);
page.on('request', (req) => {
if (['image', 'stylesheet', 'font', 'media'].includes(req.resourceType())) {
req.abort();
} else {
req.continue();
}
});
try {
await page.goto(targetUrl, { waitUntil: 'networkidle2', timeout: 30000 });
// Wait for the dynamic price element
await page.waitForSelector('[data-testid="product-price"]', { timeout: 5000 });
const products = await page.evaluate(() => {
const items = Array.from(document.querySelectorAll('.product-card'));
return items.map((el) => ({
title: el.querySelector('h2')?.textContent?.trim() || '',
price: el.querySelector('.price')?.textContent?.trim() || '',
}));
});
return products;
} finally {
await browser.close();
}
}
2. Automated Pixel-Perfect PDF Report Generation#
import puppeteer from 'puppeteer';
export async function generateInvoicePdf(htmlContent: string): Promise<Buffer> {
const browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox'] });
const page = await browser.newPage();
await page.setContent(htmlContent, { waitUntil: 'networkidle0' });
const pdfBuffer = await page.pdf({
format: 'A4',
printBackground: true,
margin: {
top: '20mm',
bottom: '20mm',
left: '15mm',
right: '15mm',
},
});
await browser.close();
return Buffer.from(pdfBuffer);
}
4 Best Practices for Headless Browser Pipelines#
--disable-dev-shm-usage in Docker: By default, Docker allocates 64MB of shared memory (/dev/shm), which causes Chromium to crash on heavy pages. This flag forces Chromium to use /tmp disk storage instead.finally Blocks: Unhandled script errors will leave zombie Chromium processes running in the background, eventually exhausting server memory.
Custom Web Automation & Data Pipelines with Rajput Bhavin#
Need automation for your business processes?
Rajput Bhavin
Systems ArchitectRelated Engineering Articles
Writing Clean Code: SOLID Principles & Modern TypeScript Refactoring Patterns
Custom Enterprise Software Development: Designing Resilient, High-Throughput Systems
Production Docker Containerization: Multi-Stage Builds, Next.js 15 & Docker Compose