Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 网站建设 > PHP > php 分析rss代码一段
【标  题】:php 分析rss代码一段
【关键字】:php,rss
【来  源】:http://blog.chinaunix.net/article.php?articleId=14584&blogId=1084

php 分析rss代码一段

Your Ad Here php 分析rss代码一段

<?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("http://bbs.chinaunix.net/rss/46.xml");
?>

关于ADODB连接数据库:【上一篇】
I LOVE PHP!:【下一篇】
【相关文章】
  • 关于PHP的分页代码
  • 简易投票系统 php+文本
  • win2k下Apache2+PHP4+MySql配置
  • 黑防黑:黑客口述—关于Php后门的隐藏技巧测试
  • php学习第一课---mysql的应用
  • php时间求法(二)
  • php与mysql三日通(三)
  • php与mysql三日通(二)
  • php与mysql三日通(四)
  • php与mysql三日通(一)
  • 【随机文章】
  • Telnet密码破解软件Letmein1.0说明
  • 简易电梯模拟程序
  • linux 调试工具 —— gdb man
  • WebService Behavior 学习心得
  • 浅谈C中的malloc和free(zz)
  • 香港地产YOHO TOWN
  • PHP and UML Class Diagrams
  • 打印时能够分页打印的CSS控制参考
  • RedHat Enterprise Linux 介绍
  • Tru64 如何支持telnet到小机
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.