Giter Site home page Giter Site logo

byrokrat-sk / register-parser Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 1.01 MB

Package for requesting structured data about business subjects from pages of slovak government websites.

License: MIT License

PHP 25.24% Shell 0.01% HTML 74.73% Dockerfile 0.02%
business-register trade-register financial-agents slovakia api parser government

register-parser's Introduction

byrokrat-sk/register-parser

This package provides access to structured data from web pages of various slovak government sites without structured API access. This package is making requests to web servers of listed pages and parsing structured data from returned HTML code (with exception to financial statements register that is providing JSON REST API).

Compatibility warning

This library is directly dependent on structure of HTML code for each data source. Keep in mind that if any of these institutions do change their HTML code structure this library will break! If this happens you are welcome to create an issue or pull request.

Use of library

Register of financial agents

<?php
require_once './vendor/autoload.php';

use \ByrokratSk\RegisterFactory;

// Allianz - Slovenská poisťovňa
$allianz = RegisterFactory::financialAgentRegister()->byNumber('195970');

echo($allianz->BusinessName . "\n");
echo($allianz->IdentificationNumber . "\n");
echo($allianz->BusinessAddress->CityName . "\n");
echo($allianz->Registrations[0]->SectorRegistrations[0]->SectorName . "\n");
echo($allianz->Registrations[0]->SectorRegistrations[0]->RegistratedAt->format('Y-m-d') . "\n");

with output:

Allianz - Slovenská poisťovňa, a.s.
00151700
Bratislava
Podregister prijímania vkladov
2017-02-16

Business register

<?php
require_once './vendor/autoload.php';

use \ByrokratSk\RegisterFactory;

$registerQuery = RegisterFactory::businessRegister();

$searchResult = $registerQuery->byName("Tesco");
$searchListing = $searchResult->first()->FullListing;
$company = $registerQuery->byListing($searchListing);

echo($company->BusinessName->getAll()[0]->BusinessName . "\n");
echo($company->BusinessName->getAll()[0]->ValidFrom->format('Y-m-d') . "\n");
echo($company->Capital->getAll()[0]->Total . ' ' . $company->Capital->getAll()[0]->Currency . "\n");

with output:

TESCO computers, s.r.o.
1999-01-18
106220.540397 EUR

Trade register

<?php
require_once './vendor/autoload.php';

use \ByrokratSk\RegisterFactory;

$company = RegisterFactory::tradeRegister()->byIdentifier('35790563');
echo($company->BusinessName . "\n");
echo($company->BusinessObjects[0]->Name . "\n");

with output:

Lidl Holding Slovenská republika, s.r.o.
Kúpa tovaru za účelom jeho predaja konečnému spotrebiteľovi (maloobchod)

Example: make yours own API end-point

<?php

require_once './vendor/autoload.php';

use \ByrokratSk\Exception\EmptySearchResultException;
use \ByrokratSk\BusinessRegister\CompanyIdValidator;
use \ByrokratSk\RegisterFactory;

$cin = $_POST['cin'];

if (empty($cin) || !CompanyIdValidator::isValid($cin)) {
    return \json_encode([
        'message' => 'CIN is not valid',
        'status' => 422,        
    ]);
}

try {
    $registerQuery = RegisterFactory::businessRegister();
    $company = $registerQuery->byIdentifier($cin);
    
    return \json_encode([
        'message' => 'Company found by CIN ' . $cin,
        'company' => $company->toArray(),
        'status' => 200,
    ]);
} catch (EmptySearchResultException $ex) {
    return \json_encode([
        'message' => 'No records for CIN ' . $cin,
        'status' => 404,
    ]);
} catch (\Exception $ex) {
    return \json_encode([
        'message' => 'Error occurred during searching for CIN ' . $cin,
        'status' => 505,
    ]);
}

Tests

Run tests native:

bash ./test.sh 

, or with docker-compose:

docker-compose up

For now tests are just for parsing logic.

Sources of data

Planned/possible future data sources

License

This library is licensed under MIT license.

Some things to catch search engines attention (is this working?)

EN: PHP, API, REST, financial agent, data, library, composer

SK: orsr, obchodný register, nbs, zrsr, živnostenský register SR, slovenská národná banka, finančný agent, knižnica, registeruz, register účtovných úzávierok, vyhľadávanie podľa IČO

register-parser's People

Contributors

dependabot[bot] avatar mrsrsen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

register-parser's Issues

Add Business Register parsing unit tests

This library do not have any unit tests for parsing HTML code of Business Register. There are some complex pages that can be used such as:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.