PHP DOMDocument :: loadHTML()返回实体的错误

时间:2014-04-06 09:56:04

标签: php curl html-parsing

我使用DOMDocument类来解析元素,但是这个类返回错误:

DOMDocument::loadHTML():Tag footer invalid in Entity

并且无法解析网页。

我使用以下脚本:

function getIpDetails( $address )
    {

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $address);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');

        $output = curl_exec($ch);
        curl_close($ch);

        $dom = new DOMDocument;
        $dom->loadHTML($output);

        ...
        ...
        ...

    }

footer是这个HTML代码:

<footer>
<div id="foot_section">
    <div id="foot_inner">
    <div id="foot_copy">All Rights Reserved.</div>
    <div id="foot_menu">
        <ul>
            <li>></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </div>
    </div>
</div>
</footer>

0 个答案:

没有答案