A two-mode automation tool built with Selenium WebDriver (Firefox) and OleDb that collects company data from a paginated, JavaScript-rendered business registry website and exports it to Excel.
- Mode 1 — ID Collector: Navigates a paginated, React/Next.js-rendered company listing, opens each company profile in a new tab, extracts the national ID from the URL, and saves it incrementally to a
.txtfile. - Mode 2 — Data Extractor: Reads national IDs from an Excel input file, visits each company's detail page, parses the HTML to extract structured fields, and writes results row-by-row into an Excel output file.
- Resume support: Both modes resume from where they left off if interrupted.
- Deduplication: Mode 2 reads already-processed IDs from the output file and skips them on re-run.
- Retry logic: Each button click retries up to 3 times on failure.
- Randomized delays: Waits a unique random interval (1–60s) between requests to avoid rate limiting.
| Layer | Technology |
|---|---|
| Language | C# (.NET Framework) |
| Browser Automation | Selenium WebDriver 4 + GeckoDriver |
| Browser | Mozilla Firefox |
| Excel I/O | Microsoft ACE OleDb 12.0 |
| HTML Parsing | Regex + string splitting |
- JavaScript-rendered pagination: The listing page uses a React/MUI component for pagination with no URL changes. Solved by targeting
aria-labelattributes on pagination buttons. - No anchor tags on cards: Company cards render without
<a>tags. Solved by clicking each card's profile button, capturing the new tab's URL, and closing it. - Per-row Excel persistence: OleDb does not flush writes until the connection closes. Solved by opening and closing a new connection per row.
- Session resume: Progress is tracked via
last_page.txtand the output Excel file itself, allowing safe interruption and restart.
.
├── src/
│ └── Program.cs # Main application
├── .gitignore
└── README.md
- .NET Framework 4.x
- Mozilla Firefox
- GeckoDriver on PATH
- Microsoft Access Database Engine (ACE OleDb 12.0)
- NuGet packages:
Selenium.WebDriver,Selenium.Support
Place input.xlsx next to the executable. The workbook must contain a sheet with a specific name in its name, with national IDs in column A.
Place an empty output.xlsx next to the executable with a sheet named Result and these headers in row 1:
NationalId | CompanyName | FoundDate | Status | CompanyType | RegisterNum | Capital | Address | Activity
=== Company Registry Extractor ===
1. Collect national IDs from company list
2. Extract company data from input.xlsx into output.xlsx
Choose (1 or 2):
Run the executable and choose a mode. For mode 1, log in manually when the browser opens, then press Enter to start collection.
- Data files (
input.xlsx,output.xlsx,national_ids.txt) are excluded from version control via.gitignore. - No credentials or sensitive data are stored in the codebase.