douyuefei3546 2015-06-30 13:44
浏览 34

如何在Simple HTML DOM中使用load_file()时忽略警告?

I use SIMPLE HTML DOM. Some pages take a long time -> then Warning (HTTP request failed) -> find() doesn`t work! FATAL ERROR! How to go to the next page?

$items = [...];
foreach ($item as $link) {
    $html = new simple_html_dom();
    $html -> load_file($link);
    if (WHAT SHOULD I WRITE HERE TO START PARSING WHEN $html is OK?) {
        some parsing
    }
}
  • 写回答

1条回答 默认 最新

  • duanbozhong9689 2015-06-30 14:55
    关注

    If the line $html -> load_file($link); is the one causing the page timeout, you can do nothing on the next line.

    Maybe consider increasing the set_time_limit or deactivating it set_time_limit(0) before the foreachloop.

    $items = [...];
    set_time_limit(300);
    foreach ($item as $link) {
        $html = new simple_html_dom();
        $html -> load_file($link);
        if (WHAT SHOULD I WRITE HERE TO START PARSING WHEN $html is OK?) {
            some parsing
        }
    }
    

    You should read the set_time_limit documentation and max execution time documentation.

    Be aware that increasing this value in a web context may not be a great idea. Also, be aware that according to PHP documentation, apache seems to have a timeout at 300 seconds (5 minutes).

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入