php - 如何修复 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;
}
?>
脚本继续加载并且不会暂停。有没有办法设置超时或异常?
解决方案
推荐阅读
- bash - sed 命令一次更改不同目录中的几个文件的名称
- javascript - NestJS HTTPS 空 @POST() 正文
- reactjs - 在 Chackra 中使用 Formik 的 useNumberInput 钩子
- dynamics-365 - Dynamics 365 App for Outlook“公司”字段未与 Dynamics 365 同步
- google-apps-script - 教育帐户企业版 Google 应用脚本的新最长执行时间是 6 分钟/执行吗?
- python - 为什么 repl.it 说“unindent 不匹配任何其他缩进级别”?我正在尝试制作一个不和谐的机器人
- perforce - 尝试撤消 Perforce P4V 中的多个修订时出错
- gcc - 将静态库链接到 exe 和共享库后的段错误
- google-apps-script - 使用 Google Apps 脚本从 google drive 文件夹中获取 Google 表格中列出的文件夹和文件
- google-sheets - 允许动态添加列的公式