php简单html dom解析器如何获取html标记的内容

php简单html dom解析器如何获取html标记的内容,php,parsing,dom,Php,Parsing,Dom,我正在尝试获取特定的标签内容,但似乎无法使用以下函数来实现 <?PHP include_once('simple_html_dom.php'); function read_page($url = 'http://google.com') { $doc = new DOMDocument(); $data = file_get_html($url); $content = $data->find('div#footer');

我正在尝试获取特定的标签内容,但似乎无法使用以下函数来实现

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

function read_page($url = 'http://google.com')
{
        $doc = new DOMDocument();

        $data = file_get_html($url);

        $content = $data->find('div#footer');

        print_r( $content);

}

read_page();
?>


试试
$data->find('div[id=“footer]”)
我厌倦了$data->find('div[id=footer]”)和$data->find('div[id=footer]”)仍然可以看到空数组耶,它返回的内容太多,所有的子代和孙子代等等。。。我需要一些简单的东西来获取内容,而不是所有的类,样式等。它应该这样做。你看过文件了吗?如果您只需要内容,不需要html,请使用:
$footer=$data->find(“#footer”,0);echo$footer->纯文本谢谢你的回复,我不再使用php进行解析了。