image problems with regular expressions

前端 未结 2 935
忘了有多久
忘了有多久 2020-12-22 04:45

When I run the following script, the image is not rendered well. What is the problem here? This is the code:



        
2条回答
  •  有刺的猬
    2020-12-22 05:36

    Use DOMDocument (I hope that your schoolmistress will not scold you):

    $dom = new DOMDocument();
    $dom->loadHTMLFile('http://www.asaphshop.nl/epages/asaphnl.sf/nl_NL/?ObjectPath=/Shops/asaphnl/Products/80203122');
    
    $xpath = new DOMXPath($dom);
    
    $url = $xpath->query('//div[@id="ProductImages"]/ul/li/a/img/@data-src-l')->item(0)->nodeValue;
    
    echo $url;
    

提交回复
热议问题