电脑爱好者,提供IT资讯信息及各类编程知识文章介绍,欢迎大家来本站学习电脑知识。 最近更新 | 联系我们 RSS订阅本站最新文章
电脑爱好者
站内搜索: 
当前位置:首页>> PHP>>新闻捕捉器:

新闻捕捉器

来源:www.cncfan.com | 2006-1-11 | (有1944人读过)



 <?
// PHP Headlines Grabber by Neil Moomey, www.neilmoomey.com.
// You are free to use this code as you wish.
// Make sure you get permission from any web sites you grab headlines from.
// You may want to write the headlines to a file on your server to speed things up.

// Grab source code from a file or web site
if(!($myFile=fopen("http://www.lndaily.com.cn/web/yw3.htm","r")))
{
echo "The news interface is down for maintenance.";
exit;
}
while(!feof($myFile))
{
// Read each line and add to $myLine
$myLine.=fgets($myFile,255);
}
fclose($myFile);
// Extract everything between start and end. You need to include these lines
//in the headlines or pick some unique substring in the html to mark the start
//and end of the news.
$start="<hr align=";
$end="建立镜像";
$start_position=strpos($myLine, $start);
$end_position=strpos($myLine, $end)+strlen($end);
$length=$end_position-$start_position;
$myLine=substr($myLine, $start_position, $length);
// Display HTML
echo $myLine;
?>
PHP热门文章排行
网站赞助商
购买此位置

 

关于我们 | 网站地图 | 文档一览 | 友情链接| 联系我们

Copyright © 2003-2024 电脑爱好者 版权所有 备案号:鲁ICP备09059398号