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();

留下评论

鄂ICP备13000209号-1

鄂公网安备 42050602000277号