校友录php源代码,月光软件站 - 编程文档 - 软件工程 - 抓取chinaren.com校友录留言的PHP小程序...

提取留言

.head { color: red; font-weight: bold; }

body { font-size: 9pt; background-color: #cccccc; }

set_time_limit(600);

function getMessage($url,$history=false)

{

$match_msg  = "/

$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   = "/

$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

{

echo "

". preg_replace($replace_names,"",$names[0][$i]) ."(";

echo $times[0][$i]."):
\n";

$message=preg_replace($replace_msg,"",$messages[0][$i])."\n\n";

echo $message;

}

}

echo "\n

执行本程序用的时间是";

echo time()-$begin;

echo "秒钟";

?>


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部