一个很简单的PHP的后端脚本,能够从(某个网中)得到最新新闻。
2008-05-01 04:01
323 查看
<?
// 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。
// 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。
相关文章推荐
- 是一个设计将LinuxFreak.org新闻标题放置到你的网站的PHP脚本程序。
- 对于一个整数矩阵,存在一种运算,对矩阵中任意元素加一时,需要其相邻(上下左右)某一个元素也加一, 现给出一正数矩阵,判断其是否能够由一个全零矩阵经过上述运算得到。
- 分享一个php的启动关闭脚本(原)
- 脚本文件中使用变量(得到当前时间,用来生成一个文件夹)
- C语言结合VBS脚本编写朗读小工具,做一个能够发音的C语言程序
- 一个php脚本占用了多少内存呢
- PHP技巧:得到一个字符串的最后一个字符
- 如何使用PHP构建一个高性能的弹幕后端服务
- 一个很简单的MYSQL数据库备份脚本
- php 小代码(2)-----给定一个字符串时间得到其时间所在的当周的周一及周日时间
- 一个不错的shell脚本学习网址-很全又很简单的课程
- G-Share 1.5beta3:一个php脚本的程序,可以把你gmail做为文档共享系统(下载系统)
- 一个很简单的php留言板。。。。搭建在sae上的。。。
- PHP引用远程脚本和一个通用引用的小例子
- 开源中国社区|纯PHP代码迭代一个表单不会有一句html代码其后端耦合度80%。
- 一个可以得到元素真实的背景颜色的javascript脚本
- 实用PHP脚本:最新县及县以上行政区划代码
- 1.2 - 第一章:PHP基础 - 解剖一个PHP脚本
- 一个php写的linux下lvm自动快照实现脚本
- 写一个脚本 从键盘让用户输入几个文件,脚本能够将此几个文件归档压缩成一个文件