Prompt
What should I use for browser automation and scraping infrastructure?
Latest observation
It depends mostly on what you’re scraping/automating, how much scale you need, and how much anti-bot pressure you’ll face. A good default stack is usually:
- Playwright for browser automation
- Python or Node.js as the main runtime
- PostgreSQL for storage
- Redis + a job queue for orchestration
- Docker for packaging
- Kubernetes or managed containers if you need scale
- A headless browser fleet only when static HTTP scraping isn’t enough
Quick recommendations
If you’re starting out
Use:
- Playwright
- Python
- Docker
- PostgreSQL
- Redis + Celery/RQ (Python) or BullMQ (Node)
This is the most practical general-purpose setup.
If you need complex browser automation
Use Playwright over Selenium in most cases:
- more reliable
- better multi-browser support
- easier waiting and network control
- stronger modern web app handling
If you only need simple scraping
Prefer:
- plain HTTP requests
- BeautifulSoup / lxml (Python) or Cheerio (Node)
Only use a browser when the site requires JS rendering, interactions, or anti-bot-sensitive flows.
Recommended infrastructure patterns
1. Small / medium scale
Best for: MVPs, internal tools, <1000 jobs/day
- API server: FastAPI / Express
- Queue: Redis
- Workers: Playwright containers
- DB: PostgreSQL
- Storage: S3-compatible object store for HTML/screenshots/artifacts
This is simple and cost-effective.
2. Larger scale
Best for: heavy crawling, many jobs, many sites
- API server
- Queue: Redis or managed queue
- Orchestrator: Kubernetes or ECS
- Workers: autoscaled browser containers
- DB: PostgreSQL
- Cache/rate limiting: Redis
- Artifact store: S3
- Observability: Prometheus/Grafana + centralized logs
This gives you isolation, scaling, and failure handling.
3. High anti-bot / sensitive targets
Best for: sites with bot detection, CAPTCHAs, aggressive throttling
- Playwright with:
- per-job isolated browser contexts
- proxy rotation
- fingerprint hardening
- human-in-the-loop fallback for CAPTCHAs
- Proxy provider
- Strong rate limiting
- Session persistence
- Retry logic with backoff
In these cases, infra matters as much as the code.
Browser automation choices
Playwright
Use this by default.
- Modern APIs
- Better reliability than Selenium for many use cases
- Good support for Chromium, Firefox, WebKit
- Excellent for intercepting network calls, emulation, downloads, auth flows
Selenium
Use when:
- you have legacy code
- you specifically need an older ecosystem or remote grid setup
- your org already uses it heavily
Puppeteer
Good, but if you’re choosing fresh today, Playwright is usually the better general choice.
Scraping architecture best practices
Separate concerns
Keep these separate:
- scheduler: decides what to scrape
- workers: do the actual fetch/automation
- parser: extracts structured data
- storage: raw and cleaned data
- monitoring: errors, timeouts, bans, success rate
Store both raw and structured data
Save:
- raw HTML
- screenshots
- response metadata
- extracted records
This makes debugging much easier.
Use queues and retries
Scraping fails often. Use:
- retries with exponential backoff
- dead-letter queues
- idempotent jobs
Rate limit aggressively
Avoid:
- hammering sites
- reusing sessions too aggressively
- parallelizing too hard on a single domain
Make jobs isolated
Each job should ideally run with:
- separate browser context
- limited lifetime
- clean cookies/cache unless persistence is needed
Common stack suggestions by language
Python stack
- Playwright
- FastAPI
- Celery or RQ
- Redis
- PostgreSQL
- SQLAlchemy / asyncpg
- BeautifulSoup / lxml / selectolax for parsing
Node.js stack
- Playwright
- NestJS / Express / Fastify
- BullMQ
- Redis
- PostgreSQL
- Cheerio for parsing
If you want a simple “default answer”
I’d choose:
- Playwright
- Python
- FastAPI
- Redis + Celery
- PostgreSQL
- Docker
- S3
- Kubernetes only when needed
That’s a strong, production-friendly foundation.
If you want, I can also give you:
- a minimal starter architecture,
- a cheap cloud deployment setup, or
- a high-scale scraping architecture.