国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

取得頁面所有不重復連接的函數

2024-05-04 23:05:01
字體:
來源:轉載
供稿:網友
  由于需要我做了個函數,實現取得頁面連接放到數組
  思路:1,取得靜態+不帶參數的:
  htm html asp php jsp cgi
  a,包含絕對路徑的處理:直接取得
  preg_match_all ()?
  b,包含相對路徑的,路徑得到處理參數:
  根據情況(. 或 .. )處理得到絕對路徑
  2,取得帶參數的:
  3,經過篩選:選擇了一些可以讀的后綴比如asp,php,html等
  連接重復的進行刪除。
  4,直接運行代碼就把 落伍者論壇 » 網站建設專欄
  第一頁面的連接拿下來到數組$e中,$e[o][0]為第一個連接;$e[o][1]為第2個
  
  
code:
<?
  $e=clinchgeturl("http://im286.com/forumdisplay.php?fid=1");
  
  var_dump($e);
  function clinchgeturl($url)
  {
  
  //$url="http://127.0.0.1/1.htm";
  //$rootpath="http://fsrootpathfsfsf/yyyyyy/";
  //var_dump($rrr);
  if(eregi('(.)*[/.](.)*',$url)){
   $roopath=split("http://",$url);
   $rootpath="http://".$roopath[2]."/";
   $nnn=count($roopath)-1;for($yu=3;$yu<$nnn;$yu++){$rootpath.=$roopath[$yu]."/";}
   // var_dump($rootpath); //http: ,'',127.0.0.1,xnml,index.php
   }
   else{$rootpath=$url;//var_dump($rootpath);
  }
  if(isset($url)){
  echo "$url 有下列褳接:<br>";
  $fcontents = file($url);
  while(list(,$line)=each($fcontents)){
  while(eregi('(href[[:space:]]*=[[:space:]]*"?[[:alnum:]:@/._-]+[/?]?[^/"]*"?)',$line,$regs)){
  //$regs[1] = eregi_replace('(href[[:space:]]*=[[:space:]]*/"?)([[:alnum:]:@/._-]+)(/"?)',"http://2",$regs[1]);
  $regs[1] = eregi_replace('(href[[:space:]]*=[[:space:]]*[/"]?)([[:alnum:]:@/._-]+[/?]?[^/"]*)(/.*)[^/"http://]*([/"]?)',"http://2",$regs[1]);
  
  if(!eregi('^http:////',$regs[1])){
  
   if(eregi('^/./.',$regs[1])){
   // $roopath=eregi_replace('(http:////)?([[:alnum:]:@/._-]+)[[:alnum:]+](/.*)[[:alnum:]+]',"http://////2",$url);
  
   $roopath=split("http://",$rootpath);
   $rootpath="http://".$roopath[2]."/";
   //echo "這是根本d :"."/n";
   $nnn=count($roopath)-1;for($yu=3;$yu<$nnn;$yu++){$rootpath.=$roopath[$yu]."/";}
   //var_dump($rootpath);
   if(eregi('^/./.[//[:alnum:]]',$regs[1])){
   //echo "這是../目錄/ :"."/n";
   //$regs[1]="../xx/xxxxxx.xx";
   // $rr=split("http://",$regs[1]);
   //for($oooi=1;$oooi<count($rr);$oooi++)
  $rrr=$regs[1];
   // {$rrr.="/".$rr[$oooi];
   $rrr = eregi_replace("^[/.][/.][//]",'',$rrr); //}
  
   $regs[1]=$rootpath.$rrr;
  
  
   }
  
  
   }else{
   if(eregi('^[[:alnum:]]',$regs[1])){ $regs[1]=$rootpath.$regs[1]; }
  
   else{ $regs[1] = eregi_replace("^[//]",'',$regs[1]);$regs[1]=$rootpath.$regs[1];}
  
   }
  
  
   }
  
  
  
  
  
  $line = $regs[2];
  if(eregi('(.)*[/.](htm|shtm|html|asp|aspx|php|jsp|cgi)(.)*',$regs[1])){
  $out[0][]=$regs[1]; }
  }
  }
  }for ($ouou=0;$ouou<count($out[0]);$ouou++)
   {
   if($out[0][$ouou]==$out[0][$ouou+1]){
  $sameurlsum=1;
  //echo "sameurlsum=1:";
   for($sameurl=1;$sameurl<count($out[0]);$sameurl++){
   if($out[0][$ouou+$sameurl]==$out[0][$ouou+$sameurl+1]){$sameurlsum++;}
   else{break;}
   }
  
  
   for($p=$ouou;$p<count($out[0]);$p++)
   { $out[0][$p]=$out[0][$p+$sameurlsum];}
   }
   }
  
  
  $i=0;
  while($out[0][++$i]) {
  //echo $root.$out[0][$i]."/r/n";
  $outed[0][$i]=$out[0][$i];
  
  }
  unset($out);
  $out=$outed; return $out;
  }
  ?>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 城固县| 泸定县| 南雄市| 威海市| 闵行区| 尚志市| 玉溪市| 延吉市| 务川| 利辛县| 乐山市| 喀喇| 宁晋县| 白玉县| 易门县| 静安区| 来安县| 呼伦贝尔市| 宁阳县| 定陶县| 浑源县| 札达县| 哈巴河县| 山西省| 阳曲县| 虞城县| 贵德县| 上高县| 巫溪县| 明星| 东乡县| 博兴县| 天长市| 巴彦淖尔市| 宝丰县| 湾仔区| 西峡县| 宝鸡市| 襄垣县| 太仆寺旗| 定州市|