首页 > 解决方案 > 如何修复 file_get_html 的超时?

问题描述

我正在尝试在网页上使用 file_get_html 来查找页面上的图像(及其 URL)。

<?php
include('simplehtmldom_1_7/simple_html_dom.php');
 $html = file_get_html('https://www.mrporter.com/en-us/mens/givenchy/jaw-neoprene--suede--leather-and-mesh-sneakers/1093998');
foreach($html->find('img') as $e)
        $img_url_array[] = $e->src . '<br>';
      $array_size = sizeof($img_url_array);
       $x =0;
        while($x <$array_size){
       echo "image url is " . $img_url_array[$x] ;
       $x =$x+1;
   }
?>

脚本继续加载并且不会暂停。有没有办法设置超时或异常?

标签: phpsimple-html-dom

解决方案


推荐阅读