GeM Document Scraper
A Python web app that scrapes and downloads contract documents from GeM (Government e-Marketplace). Enter a category, set a date range, and download all matching contract PDFs — with automatic CAPTCHA solving.
Features
- Web UI — Clean dark-themed interface, no terminal needed
- Category Search — Autocomplete from GeM's 13,000+ categories
- Auto CAPTCHA — Solves GeM's image CAPTCHAs via Tesseract OCR
- PDF Downloads — Downloads individual files or all as ZIP
- Real-time Progress — Live logs and progress bar while scraping
- Background Processing — Scraper runs in a thread, UI stays responsive
Demo
- Enter a category (e.g., "Ball Point Pens (V2) as per IS 3705")
- Set date range (DD-MM-YYYY)
- Click "Start Scraping"
- Watch live progress, download PDFs when done
Quick Start
Prerequisites
- Python 3.9+
Install
pip3 install -r requirements.txt
Run CLI (Interactive Terminal)
python3 gem_cli.py
Run Web UI
python3 app.py
Open http://localhost:5000 in your browser.
How It Works
- Search — User enters category + date range in the web UI
- CAPTCHA — Opens GeM's contract page, extracts the CAPTCHA image, reads it via Tesseract OCR, submits automatically (retries up to 15 times)
- Scrape — Collects all matching contract documents from the results
- Download — For each document, calls GeM's AJAX endpoint to get the download URL, then fetches the PDF via HTTP
- Serve — Downloaded PDFs are served back through the web UI for browsing/downloading
Project Structure
GeM-Document-Scraper/
├── app.py # Flask web server (routes, job management, threading)
├── scraper.py # Background scraping engine (Selenium + AJAX downloads)
├── actions.py # Selenium helper functions (category, dates, CAPTCHA)
├── main.py # Legacy CLI entry point (still works standalone)
├── templates/
│ └── index.html # Web UI (HTML + CSS + JS, no frameworks)
├── requirements.txt # Python dependencies
├── downloads/ # Downloaded PDFs (per job)
└── captcha/ # CAPTCHA images (temporary)
API Endpoints
| Method | Route | Description |
|---|---|---|
| GET | / |
Web UI |
| POST | /scrape |
Start a new scraping job |
| GET | /status/<job_id> |
Job status + logs + file list |
| GET | /download/<job_id>/<file> |
Download a single PDF |
| GET | /download_all/<job_id> |
Download all PDFs as ZIP |
Tested Categories
These categories are known to have contracts on GeM:
| Category | Notes |
|---|---|
Ball Point Pens (V2) as per IS 3705 |
Office supplies, high volume |
Note Sorting Machines (V2) |
Banking equipment |
LED Bulb with Battery as per IS 16102 |
Govt LED scheme |
Split Air Conditioner, Wall Mount Type (V3) ISI Marked to IS 1391 (Part 2) |
HVAC |
Nitrogen Tyre Inflators |
Automotive |
Use a wide date range (e.g., 01-01-2025 to 07-07-2025) for more results.
Date Format
The web UI accepts multiple formats and auto-converts:
DD-MM-YYYY(e.g., 01-07-2025)DD/MM/YYYY(e.g., 01/07/2025)YYYY-MM-DD(e.g., 2025-07-01)
Dependencies
| Package | Purpose |
|---|---|
| Flask | Web server |
| Selenium | Browser automation |
Tesseract OCR (pytesseract) |
CAPTCHA reading |
| Pillow | Image processing |
| Requests | HTTP file downloads |
| Gunicorn | Production WSGI server |
Deploy to Railway
- Go to railway.app → Sign up with GitHub
- Click New Project → Deploy from GitHub repo
- Select
Wickcore/gem-scrapscrap - Railway auto-detects the Dockerfile
- Click Deploy
Your app will be live at https://your-app.up.railway.app
Note: Railway gives $5 free credits/month — enough for this app.
Notes
- CAPTCHA accuracy depends on image quality; the scraper retries up to 15 times
- Headless Chrome is used — no browser window pops up
- Each scraping job runs in its own thread with its own download directory
- GeM may change their page structure, which could break selectors
License
MIT
Metadata
Release files for gem-scrapscrap 1.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gem_scrapscrap-1.7.1.tar.gz | 16.6 kB | Without provenance | Details for gem_scrapscrap-1.7.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gem_scrapscrap-1.7.1-py3-none-any.whl | Python 3 | none | any | Details for gem_scrapscrap-1.7.1-py3-none-any.whl |
Total release size: 31.3 kB
Release files / gem_scrapscrap-1.7.1.tar.gz
| Download URL | gem_scrapscrap-1.7.1.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28537775d2ea9a692470994fc8228d63cde85a1f465ec3a2a739fe7cefc152e8
|
|
BLAKE2b-256 checksum How to use checksums |
b34ed00417a93b6b059eca82d898725d6d962a5da2a1d29f265ce45f1caba724
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / gem_scrapscrap-1.7.1-py3-none-any.whl
| Download URL | gem_scrapscrap-1.7.1-py3-none-any.whl |
|---|---|
| Size | 14.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a796f90b59ba2af691727be734600f867cfceca76b2c0c6661a1511c82b93da
|
|
BLAKE2b-256 checksum How to use checksums |
a66f4a8515e5fe6afc9aad0e9a2c1d0e969e5dce0c298d604edf8a5b2443c4ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for gem-scrapscrap 1.7.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.