Php 简单HTML DOM解析器错误处理
我正在使用SimpleHTMLDOM解析器对网站进行scape,我想知道是否有任何错误处理方法。例如,如果链接断开,则在代码中前进并搜索文档是没有用的Php 简单HTML DOM解析器错误处理,php,simple-html-dom,Php,Simple Html Dom,我正在使用SimpleHTMLDOM解析器对网站进行scape,我想知道是否有任何错误处理方法。例如,如果链接断开,则在代码中前进并搜索文档是没有用的 多谢各位 循环并继续? <?php $html = file_get_html('http://www.google.com/'); foreach($html->find('a') as $element) { if(empty($element->href)) { continue; //will skip
多谢各位 循环并继续?
<?php
$html = file_get_html('http://www.google.com/');
foreach($html->find('a') as $element)
{
if(empty($element->href))
{
continue; //will skip <a> without href
}
echo $element->href . "<br>\n";
}
?>