Skip to content

A lightweight template for running Selenium-based web scraping with FastAPI on Railway. It includes headless Chromium, an optimized ChromeDriver setup, and a ready-to-use scraping endpoint, making it ideal for efficient browser automation and dependable data extraction.

Notifications You must be signed in to change notification settings

asepscareer/selenium-fastapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Selenium FastAPI

Deploy a lightweight Selenium + FastAPI scraper on Railway: headless Chromium, optimized Chrome flags, clean FastAPI service, and ready-to-extend blueprint for web scraping.

Deploy on Railway

Features

  • 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

Endpoints

Route Description
/ Basic health/status check
/scrape Example scraper using Selenium → BS4 (scrapethissite.com)

File Structure

.
├── Dockerfile
├── main.py
└── requirements.txt

How It Works

  • 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

Notes

  • 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)

About

A lightweight template for running Selenium-based web scraping with FastAPI on Railway. It includes headless Chromium, an optimized ChromeDriver setup, and a ready-to-use scraping endpoint, making it ideal for efficient browser automation and dependable data extraction.

Topics

Resources

Stars

Watchers

Forks