Deploy a lightweight Selenium + FastAPI scraper on Railway: headless Chromium, optimized Chrome flags, clean FastAPI service, and ready-to-extend blueprint for web scraping.
- Headless Chromium + Chromedriver preinstalled
- Optimized Chrome flags for low-memory Railway environments
- Simple FastAPI endpoint (
/scrape) as Selenium scraping example - BS4 for fast HTML parsing
- Minimal, reproducible Dockerfile
$PORT-aware FastAPI server
| Route | Description |
|---|---|
/ |
Basic health/status check |
/scrape |
Example scraper using Selenium → BS4 (scrapethissite.com) |
.
├── Dockerfile
├── main.py
└── requirements.txt
- Chromium & Chromedriver installed through
apt - Headless Chrome launched with safe container flags
- Selenium retrieves page HTML
- BeautifulSoup handles parsing for performance
- FastAPI exposes clean HTTP endpoints for triggering scrapes
- Suitable as a base template for any Selenium scraping workflow
- Recommended to add request queueing if scraping becomes heavy
- For production scraping, consider disabling large asset loading (images, fonts)