额系菜屁屁
注册会员

UID 75274
精华
0
积分 54
帖子 48
金钱 54 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2006-6-21
状态 离线
|
[广告]: 代充Paypal帐号美元
解析网页里的 link,包括 mailto, http, https
看到这里( http://www.phpx.com/happy/thread-119840-1-1.html )有人要 ,偶就抽空弄了个,  
<?php
/** * $Id: parseLInk.php,v 1.4 2006/06/30 06:35:00 Administrator Exp Administrator $ * * Filename : parseLInk.php * Author : Dummy | Zandy | 额系菜屁屁 * Email : [email]lianxiwoo@gmail.com[/email] | 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 = "/<a[s]([^>]+)>/is";
$preg = "/<a[s]+[^>]*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 '<xmp>'; print_r($s); echo '</xmp>'; }
?> 把文件名的 .rar 去掉。
附件: 您所在的用户组无法下载或查看附件
|  http://www.tetx.com/ |
|