Javascript PHP-DOM解析器不会返回字符串

Javascript PHP-DOM解析器不会返回字符串,javascript,php,jquery,dom,Javascript,Php,Jquery,Dom,好的,我有一个HTMLDOM解析器。它是有效的。。。索塔。它试图从一个有类的div获取文本 请参阅主文件 <!DOCTYPE HTML> <html> <head> <meta http-equiv="content-type" content="text/html" /> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1

好的,我有一个HTMLDOM解析器。它是有效的。。。索塔。它试图从一个有类的div获取文本

请参阅主文件

<!DOCTYPE HTML>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html" />

  <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
  </script>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js">
  </script>
  <style>
    #txt_out {
        border: 2px solid #C2C2C2;
        color: #2E2E2E;
        background: #EDEDED;
        width: 97%;
        padding: 5px;
        font-size: 12px;
        font-family: monospace;
        outline: none;
        height: 800px;
        margin: 10px 0;
      }
  </style>
  <title>Get Ranks</title>

  <script type="text/javascript" >   
    $(document).on("click", ".go", function (event) {

        var ID = $(".rank").val();
        console.log("Loading rank: " + ID);
        loadData(ID);


    });


    function loadData(ID) {
        var getRank = ID;

        var dataString = 'getRank=' + getRank;

        $.ajax({
            type: "POST",
            url: "otherTest.php",
            data: dataString,
            cache: false,
            success: function (html) {

                $("#txt_out").append(html);

            }
        });
    }
    </script>
  </head>
  <body>
    <h1>Get Mens Rankings</h1>

    <input value="233" class="rank" />

    <button class="go">Get stats</button>

    <textarea readonly="readonly" id="txt_out"></textarea>

  </body>
</html>

#你出去了吗{
边框:2个实心#C2C2;
颜色:#2e;
背景:#EDEDED;
宽度:97%;
填充物:5px;
字体大小:12px;
字体系列:monospace;
大纲:无;
高度:800px;
利润率:10px0;
}
排名
$(文档)。在(“单击”上,“.go”,函数(事件){
var ID=$(“.rank”).val();
console.log(“加载等级:+ID”);
装载数据(ID);
});
函数加载数据(ID){
var getRank=ID;
var dataString='getRank='+getRank;
$.ajax({
类型:“POST”,
url:“otherTest.php”,
数据:dataString,
cache:false,
成功:函数(html){
$(“#txt_out”).append(html);
}
});
}
获得男子排名
获取统计数据
单击“获取统计信息”按钮后,它(通过AJAX)调用此页面:

<?php
include_once ('simple_html_dom.php');

$rank = $_POST['getRank'];

$URL = "http://fifa.com/worldranking/rankingtable/gender=m/rank=".$rank."/confederation=25998/page=1/_ranking_table.html";

$html = file_get_html($URL);

$test = trim($html->find('.rnkdate', 0)->innertext);
echo "Date published: " . $test;

?>

它正在尝试提取从此URL发布的日期:
http://www.fifa.com/worldranking/rankingtable/gender=m/rank=233/confederation=25998/page=1/_ranking_table.html
其中
rank=XXX
是不同月份的不同表格

无论如何,当我这样做时,我得到的是:

问题是它在另一个分区内,因此。。。我猜它不会显示在
中。所以如何进入div并提取文本本身?谢谢。

如果您正在使用,那么根据,似乎您应该使用“明文”,而不是“innertext”(因为innertext似乎是javascript开发人员所称的innerHTML,而“明文”似乎是.textContent的js等价物……这个simplehtmldom库似乎是由非web开发人员编写的……无论如何)

仅供参考,simple_html_dom是一个糟糕的dom解析器,对我来说已经足够好了。
$test = trim($html->find('.rnkdate', 0)->plaintext);