首页 > 开发 > PHP > 正文

php 分析rss代码

2024-05-04 22:59:47
字体:
来源:转载
供稿:网友


  1. <?function my_headlines($url) {
  2.     $rdf = parse_url($url);
  3.     $fp = fsockopen($rdf['host'], 80, $errno, $errstr, 15);
  4.     if (!$fp) {
  5.         $content = "<font class=/"content/">problema!</font>";
  6.         return;
  7.     }
  8.     if ($fp) {
  9.         fputs($fp, "get " . $rdf['path'] . "?" . $rdf['query'] . " http/1.0/r/n");
  10.         fputs($fp, "host: " . $rdf['host'] . "/r/n/r/n");
  11.         $string = "";
  12.         while(!feof($fp)) {
  13.      $pagetext = fgets($fp,300);
  14.      $string .= chop($pagetext);
  15.  }
  16.  fputs($fp,"connection: close/r/n/r/n");
  17.  fclose($fp);
  18.  $items = explode("</item>",$string);
  19.  $content = "<font class=/"content/">";
  20.  for ($i=0;$i<10;$i++) {
  21.      $link = ereg_replace(".*<link>","",$items[$i]);
  22.      $link = ereg_replace("</link>.*","",$link);
  23.      $title2 = ereg_replace(".*<title>","",$items[$i]);
  24.      $title2 = ereg_replace("</title>.*","",$title2);
  25.      if ($items[$i] == "") {
  26.          $content = "";
  27.          return;
  28.      } else {
  29.          if (strcmp($link,$title)) {
  30.           $cont = 1;
  31.       $content .= "<img src=/"images/arrow.gif/" border=/"0/" hspace=/"5/"><a href=/"$link/" target=/"new/">$title2</a><br>/n";
  32.   }
  33.      }
  34.  }
  35.     }
  36.     echo "$content";
  37. }
  38. my_headlines
  39. ?>
上一篇:安全下载与断点续传

下一篇:rss2生成类

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表