用这个吧,我们站的星座就是这样的
http://bbs.lzjtu.cn/bbsdoc.php?board=Astrology
<?php
require("www2-funcs.php");
require("www2-board.php");
set_fromhost();
cache_header("nocache");
@$id = "username";//用户名,可以设置在系统中只允许从127.0.0.1上站
@$passwd = "password";//用户密码
$boardName = "board";//版面
$ret = bbs_check_ban_ip($id, $fromhost);
switch($ret) {
case 1:
error_alert("对不起,当前位置不允许登录该ID。");
break;
case 2:
error_alert("该 ID 不欢迎来自该 IP 的用户。");
break;
}
if (($id!="guest")&&bbs_checkpasswd($id,$passwd)!=0)
error_alert("用户密码错误,请重新登录!");
$error=bbs_wwwlogin(($kick_multi!="") ? 1 : 0, $fromhost, $fullfromhost);
switch($error) {
case 0:
case 2://normal
break;
case -1:
prompt_multilogin();
exit;
case 3:
error_alert("本帐号已停机或正在戒网");
case 5:
error_alert("登录过于频繁");
case 1:
error_alert("对不起,系统忙碌,请稍候再尝试登录");
default:
error_alert("登录错误,错误号:" . $error);
}
$data = array();
$num=bbs_getcurrentuinfo($data);
if ($data["userid"] != "guest") {
$wwwparameters = bbs_getwwwparameters();
setcookie("WWWPARAMS",$wwwparameters,0,"/");
$currentuser_num=bbs_getcurrentuser($currentuser);
if(!($currentuser["userlevel"]&BBS_PERM_LOGINOK )) {
$mainurl = "bbsnew.php";
}
$mbids = bbs_bm_get_manageable_bids();
if ($mbids) {
setcookie("MANAGEBIDS", $mbids,0,"/");
}
}
setcookie("UTMPKEY",$data["utmpkey"],0,"/");
setcookie("UTMPNUM",$num,0,"/");
setcookie("UTMPUSERID",$data["userid"],0,"/");
$brdArr=array();
$boardID= bbs_getboard($boardName,$brdArr);
$catakey = array(0,1,2,3,4,5,6,7,8,9,10,11);
$cataid = array("aries",
"taurus",
"gemini",
"cancer",
"leo",
"virgo",
"libra",
"sagittarius",
"scorpio",
"capricorn",
"aquarius",
"pisces");
$cataname = array("牡羊座",
"金牛座",
"双子座",
"巨蟹座",
"狮子座",
"处女座",
"天秤座",
"天蝎座",
"射手座",
"魔羯座",
"水瓶座",
"双鱼座");
$catadate = array("牡羊座 Aries (03/21 - 04/19)",
"金牛座 Taurus (04/20 - 05/20)",
"双子座 Gemini (05/21 - 06/21)",
"巨蟹座 Cancer (06/22 - 07/22)",
"狮子座 Leo (07/23 - 08/22)",
"处女座 Virgo (08/23 - 09/22)",
"天秤座 Libra (09/23 - 10/23)",
"天蝎座 Scorpio (10/24 - 11/22)",
"射手座 Sagittarius (11/23 - 12/21)",
"魔羯座 Capricorn (12/22 - 01/19)",
"水瓶座 Aquarius (01/20 - 02/18)",
"双鱼座 Pisces (02/19 - 03/20)");
if(isset($_GET['day'])) {
if(isset($_GET['astro'])) {
$astroid=$_GET['astro'];
getdatad($astroid,$catakey[$astroid],$cataname[$astroid],$catadate[$astroid]);
}
else
{
for ($i=0; $i<count($cataid); $i++) {
getdatad($i,$catakey[$i],$cataname[$i],$catadate[$i]);
sleep(20);
}
}
}
if(isset($_GET['week'])) {
$nextWeek = time() + (6*24*60*60);
$datezone=date('Y/n/j').'~'.date('Y/n/d',$nextWeek);
if(isset($_GET['astro'])) {
$astroid=$_GET['astro'];
getdataw($astroid,$catakey[$astroid],$cataname[$astroid],$datezone);
}
else{
for ($i=0; $i<count($cataid); $i++) {
getdataw($i,$catakey[$i],$cataname[$i],$datezone);
sleep(20);
}
}
}
bbs_wwwlogoff();
cache_header("nocache");
delete_all_cookie();
function getdatad($ckey,$cid, $cname,$cdate)
{
$url = "http://astro.sina.com.cn/pc/west/frame0_".$cid."_1.html";
$inhandle = fopen($url, "rb");
$count=0;
while(!($inhandle) && ($count<=5)) {
sleep(10);
$count=$count+1;
$inhandle = fopen($url, "rb");//尝试打开五次
}
$listpage = "";
do {
$data = fread($inhandle, 8192);
if (strlen($data) == 0) {
break;
}
$listpage .= $data;
} while(true);
fclose($inhandle);
$listpage = html2txt2day($listpage);
$title = date('Y/n/j',mktime(0, 0, 0, date("m") , date("d")+1, date("Y")))."日运程 ".$cdate;
postnews($title, $listpage);
}
function getdataw($ckey,$cid, $cname,$cdate)
{
$url = "http://astro.sina.com.cn/pc/west/frame1_".$cid.".html";
$inhandle = fopen($url, "rb");
$count=0;
while(!($inhandle) && ($count<=5)) {
sleep(10);
$count=$count+1;
$inhandle = fopen($url, "rb");//尝试打开五次
}
$listpage = "";
do {
$data = fread($inhandle, 8192);
if (strlen($data) == 0) {
break;
}
$listpage .= $data;
} while(true);
fclose($inhandle);
$listpage = html2txt2week($listpage);
$title = $cname."本周运程 (".$cdate.")";
postnews($title, $listpage);
}
function postnews($title, $text)
{
global $boardName;
$reID = 0;
$signature = 0;
$outgo = 0; //是否转信
$anony = 0; //是否匿名
settype($reID, "integer");
$articles = array();
$ret = bbs_postarticle($boardName, $title, $text, intval($signature), $reID, intval($outgo), intval($anony), 0, 0);
switch ($ret) {
case -1:
html_error_quit("错误的讨论区名称!");
break;
case -2:
html_error_quit("本版为二级目录版!");
break;
case -3:
html_error_quit("标题为空!");
break;
case -4:
html_error_quit("此讨论区是唯读的, 或是您尚无权限在此发表文章!");
break;
case -5:
html_error_quit("很抱歉, 你被版务人员停止了本版的post权利!");
break;
case -6:
html_error_quit("两次发文间隔过密,请休息几秒再试!");
break;
case -7:
html_error_quit("无法读取索引文件! 请通知站务人员, 谢谢! ");
break;
case -8:
html_error_quit("本文不可回复!");
break;
case -9:
html_error_quit("系统内部错误, 请迅速通知站务人员, 谢谢!");
break;
}
}
function html2txt2day($document)
{
// $document should contain an HTML document.
// This will remove HTML tags, javascript sections
// and white space. It will also convert some
// common HTML entities to their text equivalent.
$search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript
"'<title[^>]*?>.*?</title>'si", // Strip out title
"'<img src=\"http://image2.sina.com.cn/ast/2007index/tmp/star_php/star.gif\" width=\"18\" height=\"18\" />'i", //星星啊星星最美丽
"'<div class=\"lotstars\">'si", // 替换该行
"'<div class=\"lotconts\">'si", // 替换该行
"'</h4><p>'si", // Strip out <p>
"'<[\/\!]*?[^<>]*?>'si", // Strip out html tags, 不过滤"<a"开头的标签
"'([\r\n])[\s]+'", // Strip out white space
"'&(quot|#34);'i", // Replace html entities
"'关闭窗口'i", // Strip out 关闭窗口
"'今日运势'i",
"'明日运势'i",
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&#(\d+);'e"); // evaluate as php
$replace = array ("",
"",
"★",
"\033[1;31m------------------------------------------------\033[m",
"\033[1;31m------------------------------------------------\033[m",
":",
"",
"\\1",
"\"",
"",
"",
"",
"&",
"<",
">",
" ",
chr(161),
chr(162),
chr(163),
chr(169),
"chr(\\1)");
$text = preg_replace($search, $replace, $document);
$search = array("'(@line@)+'si");
$replace = array ("\r\n");
$text = preg_replace($search, $replace, $text);
return $text."\r\n\r\n转载自:
http://astro.sina.com.cn/";
}
function html2txt2week($document)
{
// $document should contain an HTML document.
// This will remove HTML tags, javascript sections
// and white space. It will also convert some
// common HTML entities to their text equivalent.
$search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript
"'<title[^>]*?>.*?</title>'si", // Strip out title
"'<img src=\"http://image2.sina.com.cn/ast/2007index/tmp/star_php/star.gif\" width=\"18\" height=\"18\" />'i", //星星啊星星最美丽
"'<ul class=\"daysnav\">'si",
"'\n<li class=\"date\">'si",
"'<!-- Group start -->'si",
"'<!-- 星座运势内容end -->'si",
"'<em>有对象:'si",
"'<em>没对象:'si",
"'<p>'si", // Strip out <p>
"'<br>'si", // Strip out <br>
"'</h4>\n<em>'si",
"'<[\/\!]*?[^<>]*?>'si", // Strip out html tags, 不过滤"<a"开头的标签
"'([\r\n])[\s]+'", // Strip out white space
"'&(quot|#34);'i", // Replace html entities
"'关闭窗口'i", // Strip out 关闭窗口
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&#(\d+);'e"); // evaluate as php
$replace = array ("",
"",
"★",
"@line@\033[1;31m-------------------------------------------------------------\033[m@line@",
" ----- ",
"@line@\033[1;31m-------------------------------------------------------------\033[m@line@",
"@line@\033[1;31m-------------------------------------------------------------\033[m@line@",
"@line@有对象:",
"@line@没对象:",
"@line@",
"@line@",
"@line@",
"",
"\\1",
"\"",
"",
"&",
"<",
">",
" ",
chr(161),
chr(162),
chr(163),
chr(169),
"chr(\\1)");
$text = preg_replace($search, $replace, $document);
$search = array("'(@line@)+'si");
$replace = array ("\r\n");
$text = preg_replace($search, $replace, $text);
return $text."\r\n\r\n转载自:
http://astro.sina.com.cn/";
}
?>
【 在 foxban (长白发了....) 的大作中提到: 】
: 恩,这个很简单,用php的正则表达式抓新闻,然后放到某处,呵呵
--
FROM 221.7.40.*