一個很簡單的PHP的後端指令碼,能夠從(某個網中)得到最新新聞。

來源:互聯網
上載者:User
<?
// 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    =     "  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。  


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.