我正在尝试从某个网站获取内容,但如果该网站关闭,则需要很长时间才能打开(例如 1 分钟)。
$html = new DOMDocument();
@$html->loadHtmlFile('http://somewebsite.com');
$xpath = new DOMXPath($html);
$links = $xpath->query("//p[@class='result']");
如何让它在 5 秒后超时?
最佳答案
关于php - 如何限制运行 DOMDocument->loadHtmlFile 时的超时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16601444/