抓取chinaren.com校友录留言的PHP小程序
2005-04-26 14:02
459 查看
1 <html> 2 <head> 3 <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"> 4 <metahttp-equiv="pragma"content="no-cache"> 5 <title>提取留言</title> 6 <style> 7 .head { color: red; font-weight: bold; } 8 body { font-size: 9pt; background-color: #cccccc; } 9 </style> 10 </head> 11 <body> 12 <?php 13 set_time_limit(600); 14 15 function getMessage($url,$history=false) 16 { 17 $match_msg = "/<script>do.*/('[^/n]*/"; 18 $match_date = "//d{4}-/d{2}-/d{2}/040/d{2}:/d{2}:/d{2}/"; 19 20 if($history==false){ 21 $match_names = "/&cid=.{2,6}&msg=/"; 22 $replace_names = "/&cid=|&msg=/"; 23 }else{ 24 $match_names = "/class/=/"cr5/"[^/n]*/"; 25 $replace_names = "/class/=/"cr5/" target/=/"_blank/">|<//a>/"; 26 } 27 28 $replace_msg = "/<script>|<//script>|'/d*/'|doFlatTxt/('|doStr/('| [^/n]*|/'/)|/////"; 29 $handle = fopen ($url, "r"); 30 $contensts = ""; 31 $times=""; 32 $names=""; 33 $messages=""; 34 while ($line=fgets($handle,1024)) 35 { 36 $contents .= $line; 37 } 38 //$contents = fread ($handle, 100000); 39 //echo $contents; 40 41 fclose ($handle); 42 preg_match_all($match_date,$contents,$times); 43 preg_match_all($match_names,$contents,$names); 44 preg_match_all($match_msg,$contents,$messages); 45 for($i=0;$i<count($messages[0]);$i++) 46 { 47 echo "<p><b>". preg_replace($replace_names,"",$names[0][$i]) ."</b>("; 48 echo $times[0][$i]."):<br>/n"; 49 $message=preg_replace($replace_msg,"",$messages[0][$i])."/n/n"; 50 echo $message; 51 } 52 } 53 54 $begin=time(); 55 echo "<p class=/"head/">最新留言:</p>/n"; 56 getMessage("http://alumni.chinaren.com/class/class_index.jsp?classuuid=2815032345960598103"); 57 58 echo "<p class=/"head/">更多留言:</p>/n"; 59 getMessage("http://alumni.chinaren.com/class/class_leaveword.jsp?classuuid=2815032345960598103&p=1"); 60 getMessage("http://alumni.chinaren.com/class/class_leaveword.jsp?classuuid=2815032345960598103&p=2"); 61 getMessage("http://alumni.chinaren.com/class/class_leaveword.jsp?classuuid=2815032345960598103&p=3"); 62 getMessage("http://alumni.chinaren.com/class/class_leaveword.jsp?classuuid=2815032345960598103&p=4"); 63 getMessage("http://alumni.chinaren.com/class/class_leaveword.jsp?classuuid=2815032345960598103&p=5"); 64 getMessage("http://alumni.chinaren.com/class/class_leaveword.jsp?classuuid=2815032345960598103&p=6"); 65 getMessage("http://alumni.chinaren.com/class/class_leaveword.jsp?classuuid=2815032345960598103&p=7"); 66 67 echo "<p class=/"head/">历史留言:</p>/n"; 68 for($i=0;$i<100;$i++) 69 { 70 getMessage("http://alumni.chinaren.com/class/class_leaveword2.jsp?p=".$i."&classuuid=2815032345960598103&msgtype=1&type=3",true); 71 } 72 73 echo "/n<br><center><b>执行本程序用的时间是<font color=red>"; 74 echo time()-$begin; 75 echo "</font>秒钟</b></center>"; 76 ?> 77 </body> 78 </html> 79
相关文章推荐
- http://flash.chinaren.com/ip/id.php参数传递的是什么?
- 大众点评网地点抓取程序php
- php 从http://www.weather.com.cn/上抓取天气情况
- ios DOME(http://www.cocoachina.com/bbs/read.php?tid-8101.html)
- L.A.M.P 环境部署详细步骤(转帖-http://www.phpchina.com/html/70/t-14270.html)
- 几种PHP实现网页抓取的程序代码
- php 抓取 百度快照、百度收录、百度热词程序代码, 让你的优化有了方向!
- php 模拟用户抓取网页内容程序
- 【原创】真正的驱动入门(—)[附小程序代码]作 者:CCDeath时 间:2007-12-07,23:13链 接:http://bbs.pediy.com/showthread.php?t=56192【文章标题】: 真正的驱动入门(—)[附小程序代码]【文
- 蜘蛛爬虫类程序抓取有防盗链的网站处理 php和wget命令简单破解防盗链网站的功能
- 怎样在PHP中通过ADO调用Asscess数据库和COM程序
- 转发一个PHP抓取网页快照程序
- http://www.cocoachina.com/bbs/read.php?tid-1323.html
- php 抓取天气情况 www.weather.com.cn
- php 抓取天气情况 www.weather.com.cn
- 32bit程序在64bit操作系统下处理重定向细节(转自http://bbs.pediy.com/showthread.php?t=89054)
- php抓取网站图片的程序
- 微信小程序获取openid,api.weixin.qq.com不能设为安全域名,通过php转发
- php 论坛采集程序 模拟登陆,抓取页面 实现代码
- 怎样在PHP中通过ADO调用Asscess数据库和COM程序