当前位置: 首页 > 图文教程 > 网络编程 > PHP > 一个很简单的PHP的后端脚本,能够从(某个网中)得到最新新闻。

PHP
第十三节--对象串行化 -- Classes and Objects in PHP5 [13]
第十一节--重载 -- Classes and Objects in PHP5 [11]
第十节--抽象方法和抽象类 -- Classes and Objects in PHP5 [10]
第九节--绑定 -- Classes and Objects in PHP5 [9]
第八节--访问方式 -- Classes and Objects in PHP5 [8]
第七节--类的静态成员 -- Classes and Objects in PHP5 [7]
第六节--访问属性和方法 -- Classes and Objects in PHP5 [6]
第五节--克隆 -- Classes and Objects in PHP5 [5]
第四节--构造函数和析构函数 -- Classes and Objects in PHP5 [4
第三节--定义一个类 -- Classes and Objects in PHP5 [3]
第二节--PHP5 的对象模型 -- Classes and Objects in PHP5 [2]
第一节--面向对象编程 -- Classes and Objects in PHP5 [1]
初探 PHP5 (二)
初探 PHP5 (一)
SSI使用详解(二)
SSI使用详解(一)
Cookie及其使用(二)
Cookie及其使用(一)
实现跨域名Cookie
两种统计当前在线人数的方法

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 55 ::
收藏到网摘: n/a

  <?
// sunboy's 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    =     "&nbsp;&nbsp;o";
$link_postfix    =     "<BR>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("<!-- MITTE (NEWS) -->(.*)<!-- MITTE (NEWS-UEBERBLICK) -->",
$string, $matches);
$match=str_replace("HREF="/newsticker/","href="http://www.ourjia.net/",$matches[1]);

$exp="#newsticker/data/(.*)/">(.*</FONT></B>)#i";
preg_match_all($exp, $matches[1], $matchin);

for($i=0;$i<count($matchin[1]);$i++)
   {
$body.= "$link_prefix <a href="http://www.ourjia.net/data/".$matchin[1][$i]."/">" . $matchin[2][$i]. "</a><br>n";
   }
$body = eregi_replace( "</A></FONT></B>", "", $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。  

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