百度首页 | 百度空间
 
查看文章
 
用PHP抓取新闻的例子
2008-04-17 10:29
<html>
<head>
<title>新闻</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Refresh" content="60;URL=newsthief.php">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
</head>

<body bgcolor="#FFFFFF"><center>
   <table width="80%" border="0" cellspacing="0" cellpadding="0">
     <tr align="center">
       <td height="30" bgcolor="99cc99">医保网滚动新闻</td>
     </tr>
     <tr align="center">
       <td height="30">新闻每分钟刷新一次</td>
     </tr>
    <?
$handle
= fopen("http://dailynews.sina.com.cn/news1000.shtml","r");
$sign = 0;
while(!
feof($handle))
{
    
$message = fgets($handle,512);
     if(
$sign == 1)
     {
         print(
"<tr><td>$message</td></tr>");
     }
     if(
ereg("新闻开始",$message,$result))
     {
        
$sign = 1;
     }
     else if(
ereg("新闻结束",$message,$result))
     {
        
$sign = 0;
     }
}
fclose($handle);

?>

类别:网页抓取技术的研究 | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码:
 

     

©2008 Baidu