This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
py-orsr is a Python web scraper/parser for the Slovak Commercial Register (Obchodný register SR, orsr.sk). The library extracts structured company information including:
- Company name, address, IČO (identification number)
- Registration date and legal form
- Business activities (predmet činnosti)
- Partners (spoločníci)
- Statutory bodies (štatutárny orgán)
- Supervisory board (dozorná rada)
# Install dependencies
pip3 install -r requirements.txt
# Activate virtual environment (if using venv)
source bin/activate# Run all tests
python3 -m unittest test_orsr_parser.py
# Run specific test
python3 -m unittest test_orsr_parser.py:OrsrParserTest.test_hladaj_podla_ico# Type checking (if mypy is installed)
mypy orsr.py
# Linting (if pylint/flake8 are installed)
pylint orsr.py
# or
flake8 orsr.py-
OrSr Class (
orsr.py:10-44)- Main interface for searching companies
- Two search methods:
hladaj_podla_ico()andhladaj_podla_nazvu() - Handles HTTP requests to orsr.sk with proper encoding (windows-1250)
- Extracts detail page URLs and delegates parsing to OrSrDetailParser
-
OrSrDetailParser Class (
orsr.py:46-266)- Parses HTML company detail pages into structured dictionaries
- Uses XPath expressions with lxml for HTML parsing
- Handles different record types through the
__zisti_typ_zaznamu()method - Complex parsing logic for addresses, partner information, and statutory bodies
- Encoding: All pages use
windows-1250encoding - critical for proper Slovak character handling - HTML Parsing: Uses lxml with XPath for robust element extraction
- Data Structure: Returns dictionary with consistent keys:
nazov,sidlo,ico,den_zapisu,pravna_forma,predmet_cinnosti,spolocnici,statutarny_organ,dozorna_rada - Error Handling: Methods return
Nonewhen companies are not found
requests==2.32.5- HTTP requestslxml==6.0.2- HTML/XML parsing with XPath support
The test suite (test_orsr_parser.py) includes comprehensive tests for:
- Basic search functionality by IČO and company name
- Detailed parsing for different company types (s.r.o., a.s.)
- Edge cases and complex address parsing
- Real-world company data validation
Tests use live data from orsr.sk, ensuring compatibility with the actual website structure.
- The parser is highly dependent on the HTML structure of orsr.sk
- XPath expressions may need updates when the website changes
- Address parsing contains logic for different formatting patterns
- Some methods have TODO comments for incomplete functionality (like
__nacitaj_vklady) - The codebase is in Slovak, including variable names and comments