日期:2014-05-17  浏览次数:20621 次

php使用xpath抽取网页超链接
<?php

$html=file_get_contents('http://www.163.com/');
$doc=new DomDocument();
$doc->loadHTML($html);
$xpath=new DOMXpath($doc);
foreach($xpath->query('//a/@href') as $node){
        $link = $node->nodeValue;
        echo $link . "\n";
}

?>