Search code examples
phpdomsimple-html-domphp-parser

Finding Content from Javascript using Simple HTML DOM Parser


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";
}
?>

Solution

  • 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");
    ?>