title: How do you scrape a links and images using Goutte
body: <p>I'd like to know how to scrape images using Goutte.
  when I run the following code</p>
  
  <p>$client = new Client();</p>
  
  <pre><code>    $crawler = $client-&gt;request('GET', 'http://kings.app/home');
  
      $crawler-&gt;filter('.post-preview')-&gt;each(function ($node) {
  
          $title = "&lt;p&gt;1}}".$node-&gt;filter('.post-title')-&gt;text()."&lt;/p&gt;"."&lt;br&gt;"."&lt;hr&gt;";
  
          $sub  = "&lt;p&gt;2}}".$node-&gt;filter('.post-subtitle')-&gt;text()."&lt;/p&gt;"."&lt;br&gt;";
  
          $href = $node-&gt;filter('a')-&gt;attr("href");
          $image = "&lt;p&gt;".$node-&gt;filter('img')-&gt;attr("src")."&lt;/p&gt;";
  
          $link ="&lt;a href='$href'&gt;Visit W3Schools&lt;/a&gt;";
  
          echo $image;
          echo $link;
          echo $title;
          echo $sub;
      });
  </code></pre>
  
  <p>I get the following error</p>
  
  <p>The current node list is empty.</p>
  
  <p>But if I remove</p>
  
  <pre><code> $image = "&lt;p&gt;".$node-&gt;filter('img')-&gt;attr("src")."&lt;/p&gt;";
  </code></pre>
  
  <p>and </p>
  
  <pre><code> echo $image;
  </code></pre>
  
  <p>it works fine.</p>
  
  <p>EDIT: If I add a separate crawler function under the above code like this</p>
  
  <pre><code>  $crawler-&gt;filter('img')-&gt;each(function ($node) {
  
  
          echo $node-&gt;attr('src').'&lt;br&gt;';
  
      });
  </code></pre>
  
  <p>it prints out the sources</p>
  
  <p>Also, in spite of the error, it still prints out the path. I am using Laravel, so what echo's out is above the error output. Could any one explain how I could get this to work properly so I can scrape the image. thanks </p>