PHP基于Dom方式的网页采集的实现

require('phpQuery/phpQuery.php');

$s=file_get_contents('http://tech.163.com/digi/09/0223/19/52S47HNQ001624J2.html');
$doc=phpQuery::newDocumentHTML($s);
echo '标题:'.$doc['html>body>div.endArea>div.col1>div#endMain>div.theTitle>h1#endTitle']->text();
echo '
来源:'.$doc['html>body>div.endArea>div.col1>div#endMain>div.theTitle>div.text>a:first']->text();

发表评论