2

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.

2 Answers 2

2
<?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";
}
?>
Sign up to request clarification or add additional context in comments.

Comments

0

a loop and continue?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.