Skip to content

Latest commit

 

History

History
90 lines (67 loc) · 3 KB

File metadata and controls

90 lines (67 loc) · 3 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

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)

Common Development Commands

Environment Setup

# Install dependencies
pip3 install -r requirements.txt

# Activate virtual environment (if using venv)
source bin/activate

Running Tests

# 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

Code Quality

# Type checking (if mypy is installed)
mypy orsr.py

# Linting (if pylint/flake8 are installed)
pylint orsr.py
# or
flake8 orsr.py

Architecture

Core Components

  1. OrSr Class (orsr.py:10-44)

    • Main interface for searching companies
    • Two search methods: hladaj_podla_ico() and hladaj_podla_nazvu()
    • Handles HTTP requests to orsr.sk with proper encoding (windows-1250)
    • Extracts detail page URLs and delegates parsing to OrSrDetailParser
  2. 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

Key Technical Details

  • Encoding: All pages use windows-1250 encoding - 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 None when companies are not found

Dependencies

  • requests==2.32.5 - HTTP requests
  • lxml==6.0.2 - HTML/XML parsing with XPath support

Testing

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.

Development Notes

  • 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