Custom Web Applications to Grow Your Business

(256) 429-8145

How to deal with bad url or html link in simple html dom parser

htmlSimple html dom parser is truly a simple script to parse website data that you can quickly post into perhaps a mysql table. However, when you are parsing large amount of data the parser can come across urls that are bad or just non existent. This creates an erorr "Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /simplehtmldom.php" To fixed the problem // Turn off all error reporting error_reporting(0); // Check if url exist. // If not echo an error message or do nothing if($html = file_get_html('') == '') { // echo something or do nothing echo ''; } else { $html = file_get_html(''); echo 'this one works'; } }