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

?>

你可能感兴趣的:(java,html,PHP)