程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> 一個很簡單的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    =     "&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。  

【本文版權歸作者與奧索網共同擁有,如需轉載,請注明作者及出處】    

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved