Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用简单的HTMLDOM解析器从Javascript中查找内容_Php_Dom_Simple Html Dom_Php Parser - Fatal编程技术网

Php 使用简单的HTMLDOM解析器从Javascript中查找内容

Php 使用简单的HTMLDOM解析器从Javascript中查找内容,php,dom,simple-html-dom,php-parser,Php,Dom,Simple Html Dom,Php Parser,如何使用简单的HTMLDOM解析器找到“请再次输入有效密钥”的内容 例如: <script language="javascript"> function Enable() { alert('Please enter a valid key again'); } </script> 函数Enable(){ 警报(“请再次输入有效密钥”); } 这似乎不起作用: <?php include_once("simpl

如何使用简单的HTMLDOM解析器找到“请再次输入有效密钥”的内容

例如:

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

函数Enable(){
警报(“请再次输入有效密钥”);
}
这似乎不起作用:

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

您可以用一种更简单的方法来完成:

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

您可以用一种更简单的方法来完成:

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


我不使用它,但它不是更简单更快,因为它使用编译代码来使用DOMDocument吗?然后您就可以执行$doc->getElementsByTagName(“脚本”)?或者因为你似乎只是在做字符串搜索?使用preg_match或strpos()在html字符串数据中搜索它?我不使用它,但它不是更简单更快,因为它使用编译代码来使用DOMDocument吗?然后您就可以执行$doc->getElementsByTagName(“脚本”)?或者因为你似乎只是在做字符串搜索?使用preg_match或strpos()在html字符串数据中搜索它?