use Goutte\Client;
$results = new StdClass;
$client = new Client();
$crawler = $client->request('GET', $url);
$crawler->filter('.div')->each(function ($node)
{
$item = new StdClass;
$item->test = 'hello';
$results->data[] = $item;
});
var_dump($results);
The output is var_dump($results)always a completely empty object:
object(stdClass)[176]
The URL is correct and the filter is correct, the class works, but if I use $nodeand get text from HTML, it works in a loop, but the data is not stored inside it in the $resultsObject.
As in the example above, the text 'hello' in the class $itemis not even present in the final $resultsobject.
source
share