
文章来源:
100素材网
更新时间:
2014-08-22 15:34:38
php 获取网页数据 网页php获取 php获取a标签 php 获取网页的内容
以下代码主要实现了怎样通过PHP获取一个网页上所有a标签连接,需要的朋友可以参考下
原文地址: http://www.www100sucai.com/code/1293.html
<?php
$html = file_get_contents('http://www.100sucai.com');
$dom = new DOMDocument();
@$dom->loadHTML($html);
// grab all the on the page
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body//a");
for ($i = 0; $i < $hrefs->length; $i++) {
$href = $hrefs->item($i);
$url = $href->getAttribute('href');
echo $url.'<br />';
}
?>
除非特别声明,此稿为原稿转载请注明原文链接原文地址: http://www.www100sucai.com/code/1293.html
浏览次数次
上一篇文章: PHP获取网页标题、描述和关键词的方法
下一篇文章: 英文网站网页模板html源码下载

推荐阅读:
