Goutte
Goutte copied to clipboard
Error: The current node list is empty
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?
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'; */}
Hi ssanders and thanks for the reply, I tried, but I continue to get the same mistake...
hi I have this error s.b can help me
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...