php新闻后端,一个很简单的php的后端脚本,能够从(某个网中)得到最新新闻。_php实例...

// sunboys data

// bi balo aruhan domdadu o los in wuber mongglo in huen egun i wuzhe

// zhu tuhe re hu humen tai ban nai zha bolu ya !

$link_prefix    =     "  o";

$link_postfix    =     "
n";

$cache_file    =     "tmp/heise.cache";

$cache_time    =    3600;

$items        =    0;

$time        =    split( " ", microtime());

srand((double)microtime()*1000000);

$cache_time_rnd    =    300 – rand(0, 600);

if ((!(file_exists($cache_file))) || ((filectime($cache_file) + $cache_time – $time[1]) + $cache_time_rnd < 0) || (!(filesize($cache_file))) ) {

$fp1=fopen("http://www.ourjia.net/index.shtml", "r");

$string=fread($fp1,20000);

ereg("(.*)",

$string, $matches);

$match=str_replace("HREF="/newsticker/","href="http://www.ourjia.net/",$matches[1]);

$exp="#newsticker/data/(.*)/">(.*)#i";

preg_match_all($exp, $matches[1], $matchin);

for($i=0;$i

{

$body.= "$link_prefix " . $matchin[2][$i]. "
n";

}

$body = eregi_replace( "", "", $body);

fclose($fp1);

$fpwrite = fopen($cache_file,w);

fputs($fpwrite,  "$body");

fclose($fpwrite);

}

include($cache_file);

?>

注意:1:这里的www.ourjia.net该为为有新闻更新系统的网站列如:

http://www.heise.de/newsticker。

【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值