Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielsolomon committed Jul 25, 2017
2 parents 0c86655 + e4dd6b9 commit 9695dba
Show file tree
Hide file tree
Showing 25 changed files with 2,121 additions and 37 deletions.
175 changes: 175 additions & 0 deletions .gitattributes
@@ -0,0 +1,175 @@
# Auto-detect text files, ensure they use LF.
* text=auto eol=lf

## SOURCE CODE
*.bat text eol=crlf
*.coffee text
*.css text
*.htm text
*.html text
*.inc text
*.ini text
*.js text
*.json text
*.jsx text
*.less text
*.od text
*.onlydata text
*.php text
*.pl text
*.py text
*.rb text
*.sass text
*.scm text
*.scss text
*.sh text eol=lf
*.sql text
*.styl text
*.tag text
*.ts text
*.tsx text
*.xml text
*.xhtml text

## DOCKER
*.dockerignore text
Dockerfile text

## DOCUMENTATION
*.markdown text
*.md text
*.mdwn text
*.mdown text
*.mkd text
*.mkdn text
*.mdtxt text
*.mdtext text
*.txt text
AUTHORS text
CHANGELOG text
CHANGES text
CONTRIBUTING text
COPYING text
copyright text
*COPYRIGHT* text
INSTALL text
license text
LICENSE text
NEWS text
readme text
*README* text
TODO text

## TEMPLATES
*.dot text
*.ejs text
*.haml text
*.handlebars text
*.hbs text
*.hbt text
*.jade text
*.latte text
*.mustache text
*.njk text
*.phtml text
*.tmpl text
*.tpl text
*.twig text

## LINTERS
.csslintrc text
.eslintrc text
.jscsrc text
.jshintrc text
.jshintignore text
.stylelintrc text

## CONFIGS
*.bowerrc text
*.cnf text
*.conf text
*.config text
.browserslistrc text
.editorconfig text
.gitattributes text
.gitconfig text
.gitignore text
.htaccess text
*.npmignore text
*.yaml text
*.yml text
browserslist text
Makefile text
makefile text

## HEROKU
Procfile text
.slugignore text

## GRAPHICS
*.ai binary
*.bmp binary
*.eps binary
*.gif binary
*.ico binary
*.jng binary
*.jp2 binary
*.jpg binary
*.jpeg binary
*.jpx binary
*.jxr binary
*.pdf binary
*.png binary
*.psb binary
*.psd binary
*.svg text
*.svgz binary
*.tif binary
*.tiff binary
*.wbmp binary
*.webp binary

## AUDIO
*.kar binary
*.m4a binary
*.mid binary
*.midi binary
*.mp3 binary
*.ogg binary
*.ra binary

## VIDEO
*.3gpp binary
*.3gp binary
*.as binary
*.asf binary
*.asx binary
*.fla binary
*.flv binary
*.m4v binary
*.mng binary
*.mov binary
*.mp4 binary
*.mpeg binary
*.mpg binary
*.swc binary
*.swf binary
*.webm binary

## ARCHIVES
*.7z binary
*.gz binary
*.rar binary
*.tar binary
*.zip binary

## FONTS
*.ttf binary
*.eot binary
*.otf binary
*.woff binary
*.woff2 binary

## EXECUTABLES
*.exe binary
*.pyc binary
6 changes: 4 additions & 2 deletions .idea/inspectionProfiles/Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/mfinante.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 44 additions & 2 deletions README.md
@@ -1,2 +1,44 @@
# mfinante
Php Scrapper for mfinainte website
PHP MFinante Data Scraper
=============
Php Scrapper for mfinante.ro website

## Usage example
Calls to mfinante website will take ~15 seconds.
This is because of the use phantom JS browser to parse the javascript
needed to load the mfinante.ro

##### Getting company data.
``` php
use ByTIC\MFinante\MFinante;
$companyData = MFinante::cif($companyCif);
```

##### Getting company balance sheet data.
``` php
use ByTIC\MFinante\MFinante;
$balanceSheetData = MFinante::balanceSheet($companyCif, $year);
```


## Installation
It is recommended that you use Composer to install PHP PhantomJS.
First, add the following to your project’s composer.json file:
``` composer.json
#composer.json

"scripts": {
"post-install-cmd": [
"ByTIC\\MFinante\\Composer\\PhantomInstaller::installPhantomJS"
],
"post-update-cmd": [
"ByTIC\\MFinante\\Composer\\PhantomInstaller::installPhantomJS"
]
}
```

Finally, install the library from the root of your project:
``` bash
$ composer require bytic/mfinante
```

## Changelog
3 changes: 0 additions & 3 deletions composer.json
Expand Up @@ -13,9 +13,6 @@
"ByTIC\\MFinante\\": "src/"
}
},
"config": {
"bin-dir": "bin"
},
"require": {
"php": "^7.0",
"fabpot/goutte": "^3.2",
Expand Down
12 changes: 3 additions & 9 deletions src/Clients/PhantomJs/ClientBridge.php
Expand Up @@ -2,10 +2,10 @@

namespace ByTIC\MFinante\Clients\PhantomJs;

use JonnyW\PhantomJs\Client as PhantomJsBaseClient;
use GuzzleHttp\ClientInterface as GuzzleClientInterface;
use JonnyW\PhantomJs\Client as PhantomJsBaseClient;
use PhantomInstaller\PhantomBinary;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

/**
* Class PhantomJsClientBridge
Expand Down Expand Up @@ -79,13 +79,7 @@ protected function getPhantomJsClient()
{
if ($this->phantomJsClient === null) {
$this->phantomJsClient = PhantomJsBaseClient::getInstance();

$uname = strtolower(php_uname());

if (strpos($uname, 'win') !== false) {
$this->phantomJsClient->getEngine()->setPath(dirname(dirname(dirname(__DIR__))) . '/bin/phantomjs.exe');

}
$this->phantomJsClient->getEngine()->setPath(PhantomBinary::getBin());
}
return $this->phantomJsClient;
}
Expand Down
13 changes: 13 additions & 0 deletions src/Composer/PhantomInstaller.php
@@ -0,0 +1,13 @@
<?php

namespace ByTIC\MFinante\Composer;

use PhantomInstaller\Installer;

/**
* Class PhantomInstaller
* @package ByTIC\MFinante\Composer
*/
class PhantomInstaller extends Installer
{
}
13 changes: 13 additions & 0 deletions src/Exception/AbstractException.php
@@ -0,0 +1,13 @@
<?php

namespace ByTIC\MFinante\Exception;

use Exception;

/**
* Class AbstractException
* @package ByTIC\MFinante\Exception
*/
abstract class AbstractException extends Exception
{
}
11 changes: 11 additions & 0 deletions src/Exception/InvalidArgumentException.php
@@ -0,0 +1,11 @@
<?php

namespace ByTIC\MFinante\Exception;

/**
* Class InvalidCifException
* @package ByTIC\MFinante\Exception
*/
class InvalidArgumentException extends AbstractException
{
}
4 changes: 1 addition & 3 deletions src/Exception/InvalidCifException.php
Expand Up @@ -2,12 +2,10 @@

namespace ByTIC\MFinante\Exception;

use RuntimeException;

/**
* Class InvalidCifException
* @package ByTIC\MFinante\Exception
*/
class InvalidCifException extends RuntimeException
class InvalidCifException extends AbstractException
{
}
21 changes: 17 additions & 4 deletions src/MFinante.php
Expand Up @@ -2,7 +2,10 @@

namespace ByTIC\MFinante;

use ByTIC\MFinante\Scrapers\CompanyPage;
use ByTIC\MFinante\Parsers\BalanceSheetPage as BalanceSheetPageParser;
use ByTIC\MFinante\Parsers\CompanyPage as CompanyPageParser;
use ByTIC\MFinante\Scrapers\BalanceSheetPage as BalanceSheetPageScraper;
use ByTIC\MFinante\Scrapers\CompanyPage as CompanyPageScraper;

/**
* Class MFinante
Expand All @@ -12,10 +15,20 @@ class MFinante
{
/**
* @param $cif
* @return bool
* @return CompanyPageParser
*/
public static function cif(int $cif)
public static function cif($cif)
{
return (new CompanyPage($cif))->execute();
return (new CompanyPageScraper($cif))->execute();
}

/**
* @param int $cif
* @param int $year
* @return BalanceSheetPageParser
*/
public static function balanceSheet($cif, $year)
{
return (new BalanceSheetPageScraper($cif, $year))->execute();
}
}

0 comments on commit 9695dba

Please sign in to comment.