tags:

views:

322

answers:

2

Hello,

I'm using SimpleHTMLDOM Parser to scape a website and I would like to know if there's any error handling method. For example, if the link is broken there is no use to advance in the code and search the document.

Thank you.

A: 

a loop and continue?

Adrián
A: 
<?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";
}
?>
warpech