1

How do I find the content "Please enter a valid key again" using Simple HTML DOM Parser?

Example:

<script language="javascript">
     function Enable() {      
        alert('Please enter a valid key again');
     }
</script>

This don't seem to work:

<?php

include_once("simple_html_dom.php");

$html = file_get_html("incorrect.html");

$ret = $html->find("Please enter a valid key again", 0);

if ($ret) {
    echo "found";
} else {
    echo "not found";
}
?>
hakre
  • 193,403
  • 52
  • 435
  • 836
user622378
  • 2,318
  • 6
  • 42
  • 63
  • I don't use that, but wouldn't it be more simple and faster, because its using compiled code, to use DOMDocument? Then you can just do a $doc->getElementsByTagName("script"); ? or since you seem to be just doing a string search? using preg_match or strpos() to search for it in the html string data? – Rahly Jun 30 '11 at 23:20

1 Answers1

4

You can do this in a simpler way:

<?php    
include_once("simple_html_dom.php");        
$html = file_get_html('incorrect.html');
(strstr($html,'Please enter a valid key again')) ? print("found") : print("not found");
?>
Regis
  • 142
  • 5