软件工程

本类阅读TOP10

·PHP4 + MYSQL + APACHE 在 WIN 系统下的安装、配置
·Linux 入门常用命令(1)
·Linux 入门常用命令(2)
·使用 DCPROMO/FORCEREMOVAL 命令强制将 Active Directory 域控制器降级
·DirectShow学习(八): CBaseRender类及相应Pin类的源代码分析
·基于ICE方式SIP信令穿透Symmetric NAT技术研究
·Windows 2003网络负载均衡的实现
·一网打尽Win十四种系统故障解决方法
·数百种 Windows 软件的免费替代品列表
·收藏---行百里半九十

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
抓取chinaren.com校友录留言的PHP小程序

作者:未知 来源:月光软件站 加入时间:2005-5-13 月光软件站

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="pragma" content="no-cache">
<title>提取留言</title>
<style>
.head { color: red; font-weight: bold; }
body { font-size: 9pt; background-color: #cccccc; }
</style>
</head>
<body>
<?php
set_time_limit(600);

function getMessage($url,$history=false)
{
 $match_msg  = "/<script>do.*\('[^\n]*/";
 $match_date  = "/\d{4}-\d{2}-\d{2}\040\d{2}:\d{2}:\d{2}/";
 
 if($history==false){
 $match_names   = "/&cid=.{2,6}&msg=/"; 
 $replace_names = "/&cid=|&msg=/";
 }else{
 $match_names   = "/class\=\"cr5\"[^\n]*/";
 $replace_names = "/class\=\"cr5\" target\=\"_blank\">|<\/a>/";
 }

 $replace_msg   = "/<script>|<\/script>|'\d*\'|doFlatTxt\('|doStr\('|&nbsp[^\n]*|\'\)|\\\\/";
 $handle = fopen ($url, "r");
 $contensts = "";
 $times="";
 $names="";
 $messages="";
 while ($line=fgets($handle,1024))
 {
  $contents .= $line;
 }
 //$contents = fread ($handle, 100000);
 //echo $contents;

 fclose ($handle);
 preg_match_all($match_date,$contents,$times);
 preg_match_all($match_names,$contents,$names);
 preg_match_all($match_msg,$contents,$messages);
 for($i=0;$i<count($messages[0]);$i++)
 {
  echo "<p><b>". preg_replace($replace_names,"",$names[0][$i]) ."</b>(";
  echo $times[0][$i]."):<br>\n";
  $message=preg_replace($replace_msg,"",$messages[0][$i])."\n\n";
  echo $message;
 }
}

$begin=time();
echo "<p class=\"head\">最新留言:</p>\n";
getMessage("http://alumni.chinaren.com/class/class_index.jsp?classuuid=2815032345960598103");

echo "<p class=\"head\">更多留言:</p>\n";
getMessage("http://alumni.chinaren.com/class/class_leaveword.jsp?classuuid=2815032345960598103&p=1");
getMessage("http://alumni.chinaren.com/class/class_leaveword.jsp?classuuid=2815032345960598103&p=2");
getMessage("http://alumni.chinaren.com/class/class_leaveword.jsp?classuuid=2815032345960598103&p=3");
getMessage("http://alumni.chinaren.com/class/class_leaveword.jsp?classuuid=2815032345960598103&p=4");
getMessage("http://alumni.chinaren.com/class/class_leaveword.jsp?classuuid=2815032345960598103&p=5");
getMessage("http://alumni.chinaren.com/class/class_leaveword.jsp?classuuid=2815032345960598103&p=6");
getMessage("http://alumni.chinaren.com/class/class_leaveword.jsp?classuuid=2815032345960598103&p=7");

echo "<p class=\"head\">历史留言:</p>\n";
for($i=0;$i<100;$i++)
{
 getMessage("http://alumni.chinaren.com/class/class_leaveword2.jsp?p=".$i."&classuuid=2815032345960598103&msgtype=1&type=3",true);
}

echo "\n<br><center><b>执行本程序用的时间是<font color=red>";
echo time()-$begin;
echo "</font>秒钟</b></center>";
?>
</body>
</html>




相关文章

相关软件