bytic / mfinante

Php Scrapper for mfinainte website
MIT License
1 stars 0 forks source link

The DOM crawler doesn't return content #2

Open ghost opened 6 years ago

ghost commented 6 years ago

I've set up the project and run it as normal and nothing happened so I've made a dump on the crawler request in CompanyPage.php and this is what I get, no matter what CIF I enter. Also, in AbstractParser.php on getModel() method, $model->setParameters() was receiving the $model object not $parameters object. Anyways, the issue is with the crawler I guess...

 object(Symfony\Component\DomCrawler\Crawler) 
{
  "protected:uri" => string(58) "http://www.mfinante.gov.ro/infocodfiscal.html?cod=30232096"
  "private:Symfony\Component\DomCrawler\Crawler:defaultNamespacePrefix" => string(7) "default"
  "private:Symfony\Component\DomCrawler\Crawler:namespaces" =>  NULL
  "private:Symfony\Component\DomCrawler\Crawler:baseHref" => string(58) "http://www.mfinante.gov.ro/infocodfiscal.html?cod=30232096"
  "private:Symfony\Component\DomCrawler\Crawler:document" =>  object(DOMDocument) 
    {
    }
  "private:Symfony\Component\DomCrawler\Crawler:nodes" => array(1) {
      0 =>  object(DOMElement) 
        {
        }
    }
  "private:Symfony\Component\DomCrawler\Crawler:isHtml" => bool(true)
}
gabrielsolomon commented 6 years ago

Hello,

I think you did not call getContents. I updated the exemples and wiki now to make this more obvious.

$companyData = MFinante::cif($companyCif)->getContent();

ghost commented 6 years ago

I see but...it returns just:

array(2) {
  "cif" => string(8) "30232096"
  "balance_sheets" => array(4) {
      0 => string(4) "2012"
      1 => string(4) "2013"
      2 => string(4) "2014"
      3 => string(4) "2015"
    }
}

for MFinante::cif($companyCif)->getContent();

and for MFinante:balanceSheet($companyCif, $year)->getContent(); returns The current node list is empty. screen shot 2018-01-08 at 18 36 08

Zet-Abovo commented 6 years ago

Hi, I installed the crawler on a xampp localhost, and it returns "The current node list is empty" error. Here is the full error message:

Fatal error: Uncaught InvalidArgumentException: The current node list is empty. in C:\xampp\htdocs\mfinante-1.0.4\vendor\symfony\dom-crawler\Crawler.php:581 Stack trace: #0 C:\xampp\htdocs\mfinante-1.0.4\src\Parsers\CompanyPage.php(41): Symfony\Component\DomCrawler\Crawler->html() #1 C:\xampp\htdocs\mfinante-1.0.4\src\Parsers\CompanyPage.php(21): ByTIC\MFinante\Parsers\CompanyPage->parseCif() #2 C:\xampp\htdocs\mfinante-1.0.4\src\Parsers\AbstractParser.php(43): ByTIC\MFinante\Parsers\CompanyPage->generateContent() #3 C:\xampp\htdocs\mfinante-1.0.4\proba.php(9): ByTIC\MFinante\Parsers\AbstractParser->getContent() #4 {main} thrown in C:\xampp\htdocs\mfinante-1.0.4\vendor\symfony\dom-crawler\Crawler.php on line 581