title: Get image URL inside an element from external website - Laravel
body: <p>As the problem I've mentioned <a href="https://stackoverflow.com/questions/69099214/intervention-image-exception-not-readable-exception-unable-to-init-from-given-b">here</a>. I'm going to try alternative way of getting an image url. I want to get the product image url from <a href="https://www.matchesfashion.com/products/Adidas-By-Stella-McCartney-Metallic-zebra-print-Primegreen-leggings-1424516" rel="nofollow noreferrer">https://www.matchesfashion.com/products/Adidas-By-Stella-McCartney-Metallic-zebra-print-Primegreen-leggings-1424516</a> and if you inspect the product image it can be access inside a <code>&lt;figure&gt;&lt;/figure&gt;</code> element. I did some reseach and wrote this code to get content from an external webpage. But it didn't return anything.</p>
  <pre><code>$doc = new DOMDocument;
  
  
  $doc-&gt;preserveWhiteSpace = false;
  
  
  $doc-&gt;strictErrorChecking = false;
  $doc-&gt;recover = true;
  
  $doc-&gt;loadHTMLFile('https://www.matchesfashion.com/products/Adidas-By-Stella-McCartney-Metallic-zebra-print-Primegreen-leggings-1424516');
  
  $xpath = new DOMXPath($doc);
  
  $var = $xpath-&gt;evaluate('string(//figure[@class=&quot;iiz&quot;])');
  </code></pre>
  <p>I just need to get the source url of that image So I can continue my Image encoding process. Thanks in advance</p>