最新消息: 新版网站上线了!!!

PHP 获取远程页面所有连接

<?php
  header("Content-type:text/html;charset=utf-8");
  function get($url)
  {
 $data=file_get_contents($url);
  preg_match_all('/<a\s+href="?([^>"]+)"?\s*[^>]*>([^>]+)<\/a>/i',$data,$arr);
 return array('title'=>$arr[2],'link'=>$arr[1]);
}
  $url="http://www.kuitao8.com";
  $d=get($url);
  print "<base href=$url target=_blank>";
foreach($d['title'] as $i=>$title){
  print "<a href={$d['link'][$i]}>$title</a><br>";
  }
  ?>

转载请注明:谷谷点程序 » PHP 获取远程页面所有连接