I am trying to detect a couple things from a url.
- is it valid
-
does it have a specific div in it
$url = 'http://www.google.com/aasdsasdfafddsgsagf'; $dom = new DOMDocument; libxml_use_internal_errors(true); $request = $dom->loadHTMLFile($url); $DOMxpath = new DOMXPath($dom); $title = $DOMxpath->query("//span[@class='bluebar']") if(!$request || $title->length == 0){ echo 'failed!!'; }
I am trying to get this conditions:
if the page loads and it does not have the div - do nothing.
if the page does not load - do nothing.
Right now I am getting this error which stops everything that comes after it from running properly.
error:
Warning: DOMDocument::loadHTMLFile(http://www.google.com/aasdsasdfafddsgsagf): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in...
I still get the echo 'failed!!'.
Please help!!