| 网站首页 | 文章中心 | 下载中心 | 图片中心 | 访客留言 | 数码商城 | 毕设、论文 | 彩票 | 
您现在的位置: 有昌网络 >> 文章中心 >> 特别研究 >> PHP技术区! >> 文章正文 用户登录 新用户注册
php 分析rss代码一段         ★★★
php 分析rss代码一段
作者:xiaochan… 文章来源:本站原创 点击数: 更新时间:2005-10-21 14:10:59

<?php
function my_headlines($url) {
    $rdf = parse_url($url);
    $fp = fsockopen($rdf[ host ], 80, $errno, $errstr, 15);
    if (!$fp) {
        $content = "<font class=\"content\">Problema!</font>";
        return;
    }
    if ($fp) {
        fputs($fp, "GET " . $rdf[ path ] . "?" . $rdf[ query ] . " HTTP/1.0\r\n");
        fputs($fp, "HOST: " . $rdf[ host ] . "\r\n\r\n");
        $string = "";
        while(!feof($fp)) {
     $pagetext = fgets($fp,300);
     $string .= chop($pagetext);
 }
 fputs($fp,"Connection: close\r\n\r\n");
 fclose($fp);
 $items = explode("</item>",$string);
 $content = "<font class=\"content\">";
 for ($i=0;$i<10;$i++) {
     $link = ereg_replace(".*<link>","",$items[$i]);
     $link = ereg_replace("</link>.*","",$link);
     $title2 = ereg_replace(".*<title>","",$items[$i]);
     $title2 = ereg_replace("</title>.*","",$title2);
     if ($items[$i] == "") {
         $content = "";
         return;
     } else {
         if (strcmp($link,$title)) {
          $cont = 1;
      $content .= "<img src=\"images/arrow.gif\" border=\"0\" hspace=\"5\"><a href=\"$link\" target=\"new\">$title2</a><br>\n";
  }
     }
 }
    }
    echo "$content";
}


my_headlines
?>


文章录入:xiaochang    责任编辑:xiaochang 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    专 题 栏 目
    最 新 热 门
    最 新 推 荐
    相 关 文 章
    PHP的日期时间函数date(
    C Java PHP Perl Python
    windows 下配置 apache 
    【分享】PHP 电子书集合
    Windows环境下smarty安装
    PHP分页的类
    一个生成静态页面的类
    php与mysql三日通!
    很有用的php函数
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)