title: Getting image source in php is extremely slow
body: <p>I need to get the image src based on the class of the image.
  This is the code I wrote.
  It works but it is extremely slow.</p>
  <pre><code>$url='https://' . $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
  $html= file_get_contents($url);
  $doc = new DOMDocument();
  libxml_use_internal_errors(true);
  $doc-&gt;loadHTML($html);
  $xpath = new DOMXPath($doc);
  $nodes = $xpath-&gt;query(&quot;//img[@class='imgbanner']&quot;);
  
  if ($nodes-&gt;length &gt; 0) {
      $src = $nodes-&gt;item(0)-&gt;getAttribute('src');
  }
  
  else {
      $src = null;
  }
  </code></pre>
  <p>Any clues on how to improve speed?</p>