Goutte icon indicating copy to clipboard operation
Goutte copied to clipboard

Error: The current node list is empty

Open Ande1232 opened this issue 7 years ago • 4 comments

Hi, I'm estract out the metacritic of the game, only if the game does not have a metacritic, it shows me the error:

(1/1) InvalidArgumentExceptionThe current node list is empty.
--
in Crawler.php (line 584)

This is my code. (Checkoline is a feature that you can see here)

if (checkOnline('http://www.metacritic.com/game/'.str_slug($console->nome_cat, '-').'/'.$giochi->slug))
{
  $client = new Client();

  $crawler = $client->request(
      'GET',
      'http://www.metacritic.com/game/'.str_slug($console->nome_cat, '-').'/'.$giochi->slug
  );
  $metacritic = $crawler->filterXPath('//*[@id="main"]/div/div[3]/div/div/div[2]/div[1]/div[1]/div/div/a/div/span')->html();
}

If the page exists he prints me correctly the metascore, but how do I do that if it does not exist ignore the crawler?

Ande1232 avatar Jul 20 '17 12:07 Ande1232

Try wrapping your code in a try-catch statement.

try
{
  if (checkOnline('http://www.metacritic.com/game/'.str_slug($console->nome_cat, '-').'/'.$giochi->slug))
  {
    $client = new Client();
    
    $crawler = $client->request(
        'GET',
        'http://www.metacritic.com/game/'.str_slug($console->nome_cat, '-').'/'.$giochi->slug
    );
    $metacritic = $crawler->filterXPath('//*[@id="main"]/div/div[3]/div/div/div[2]/div[1]/div[1]/div/div/a/div/span')->html();
  }
}
catch (Exception $e) {/* echo 'error'; */}

ssanders avatar Jul 20 '17 15:07 ssanders

Hi ssanders and thanks for the reply, I tried, but I continue to get the same mistake...

Ande1232 avatar Jul 20 '17 18:07 Ande1232

hi I have this error s.b can help me

ngrcode avatar Sep 04 '18 05:09 ngrcode

the same issue. have no idea how to fix. the filtered object is present on the page, but it return an exception with empty node list...

tabbakka-developer avatar Dec 18 '18 15:12 tabbakka-developer