Home > Backend Development > PHP Tutorial > A very simple PHP back-end script that can get the latest news from (a certain network). _PHP Tutorial

A very simple PHP back-end script that can get the latest news from (a certain network). _PHP Tutorial

WBOY
Release: 2016-07-13 17:31:39
Original
1096 people have browsed it

// 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。  

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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/509058.htmlTechArticle? // 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...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template