![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
看到这里( http://www.phpx.com/happy/thread-119840-1-1.html )有人要 ,偶就抽空弄了个,


[php]
<?php
/**
* $Id: parseLInk.php,v 1.4 2006/06/30 06:35:00 Administrator Exp Administrator $
*
* Filename : parseLInk.php
* Author : Dummy | Zandy | 额系菜屁屁
* Email : lianxiwoo@gmail.com | hotmail.com
* Create : 200605
* LastMod : 2006
* Usage :
*/
ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE);
//header("Content-type:text/html;charset=utf-8");
$url = 'http://www.phpx.com/happy/thread-119840-1-1.html';
$url = 'http://www.phpx.com/happy/thread-119396-7-1.html';
$parse_url = parse_url($url);
p($parse_url);
$url_pre = $parse_url['scheme'].'://'.$parse_url['host'].dirname($parse_url['path']);
$urls = array(); // 将解析保存结果
$a = file_get_contents($url);
$preg = "/\]+)\>/is";
$preg = "/\]*href\=[\"']?([^>'\"]+)[\"']?[^>]*\>/is";
$s = preg_match_all($preg, $a, $m);
p($m);
foreach ($m[1] as $k => $v){
$v = trim($v);
if (substr($v, 0, 1) == '#'){
continue;
}elseif (strtolower(substr($v, 0, 6)) == 'mailto'){
$v = trim(strstr($v, ":"));
$v = trim(substr($v, 1));
if (strlen($v) <= 3 || false === strpos($v, '@')){
continue;
}
$urls['mailto'][] = $v;
}elseif (strtolower(substr($v, 0, 5)) == 'https') {
if (false !== strpos($v, " ")){
$v = substr($v, 0, strpos($v, " "));
}
if (strlen($v) <= 8){
continue;
}
$urls['https'][] = $v;
}elseif (strtolower(substr($v, 0, 4)) == 'http') {
if (false !== strpos($v, " ")){
$v = substr($v, 0, strpos($v, " "));
}
if (strlen($v) <= 7){
continue;
}
$urls['http'][] = $v;
}else{
if (false !== strpos($v, " ")){
$v = substr($v, 0, strpos($v, " "));
}
if ($v && substr($v, 0, 1) != '/'){
$v = '/'.$v;
}
$urls['http'][] = $url_pre.$v;
}
}
p($urls); // 打印解析结果
/**
*
* @createtime
* @author Dummy | Zandy
* @modifiedby $LastChangedBy: $
* @param
* @return
* @throws none
*/
function p($s){
echo '
print_r($s);
echo '
}
?>[/php]
把文件名的 .rar 去掉。![]()
parseLink.php.rar

