由于需要我做了个函数,实现取得页面连接放到数组里
思路: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("\/",$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:]:@/._-]+)(\"?)',"\\2",$regs[1]);
$regs[1] = eregi_replace('(href[[:space:]]*=[[:space:]]*[\"]?)([[:alnum:]:@/._-]+[\?]?[^\"]*)(\.*)[^\"\/]*([\"]?)',"\\2",$regs[1]);
if(!eregi('^http:\/\/',$regs[1])){
if(eregi('^\.\.',$regs[1])){
// $roopath=eregi_replace('(http:\/\/)?
思路: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个
$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("\/",$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:]:@/._-]+)(\"?)',"\\2",$regs[1]);
$regs[1] = eregi_replace('(href[[:space:]]*=[[:space:]]*[\"]?)([[:alnum:]:@/._-]+[\?]?[^\"]*)(\.*)[^\"\/]*([\"]?)',"\\2",$regs[1]);
if(!eregi('^http:\/\/',$regs[1])){
if(eregi('^\.\.',$regs[1])){
// $roopath=eregi_replace('(http:\/\/)?
| 对此文章发表了评论 |
