php源代码及代码详细解释如下: 

 rss.jpg

就是加载多了有点慢!不然还挺好用的!确实好玩

  1. <?php
  2. //RSS源地址列表数组
  3. $rssfeed = array("https://www.huhexian.com/feed",
  4. "http://pfzlcx.cn//rss.php",
  5. "https://www.iyuren.com/feed",
  6. "https://www.macrr.com/feed");
  7.  
  8. //设置编码为UTF-8
  9. header('Content-Type:text/html;charset= UTF-8');
  10.  
  11. for($i=0;$i<sizeof($rssfeed);$i++){//分解开始
  12. $buff = "";
  13. $rss_str="";
  14. //打开rss地址,并读取,读取失败则中止
  15. $fp = fopen($rssfeed[$i],"r") or die("can not open $rssfeed");
  16. while ( !feof($fp) ) {
  17. $buff .= fgets($fp,4096);
  18. }
  19. //关闭文件打开
  20. fclose($fp);
  21.  
  22. //建立一个 XML 解析器
  23. $parser = xml_parser_create();
  24. //xml_parser_set_option -- 为指定 XML 解析进行选项设置
  25. xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
  26. //xml_parse_into_struct -- 将 XML 数据解析到数组$values中
  27. xml_parse_into_struct($parser,$buff,$values,$idx);
  28. //xml_parser_free -- 释放指定的 XML 解析器
  29. xml_parser_free($parser);
  30.  
  31. foreach ($values as $val) {
  32. $tag = $val["tag"];
  33. $type = $val["type"];
  34. $value = $val["value"];
  35. //标签统一转为小写
  36. $tag = strtolower($tag);
  37.  
  38. if ($tag == "item" && $type == "open"){
  39. $is_item = 1;
  40. }else if ($tag == "item" && $type == "close") {
  41. //构造输出字符串
  42. $rss_str .= "<a href='".$link."' target=_blank>".$title."</a><br />";
  43. $is_item = 0;
  44. }
  45. //仅读取item标签中的内容
  46. if($is_item==1){
  47. if ($tag == "title") {$title = $value;}
  48. if ($tag == "link") {$link = $value;}
  49. }
  50. }
  51. //输出结果
  52. echo $rss_str."<br />";
  53. }
  54. ?>


php简单获取版: 


  1. <?php
  2. $xml=simplexml_load_file('http://pfzlcx.cn/rss.php');
  3. foreach($xml->channel->item as $item){
  4. echo '<a href="'.$item->link.'">';
  5. echo $item->title;
  6. echo '</a>';
  7. echo '<br/>';
  8. $des=str_replace(' ','',str_replace(' ','',strip_tags($item->description)));
  9. $des=str_replace("\n",'',$des);
  10. $des=str_replace("\r",'',$des);
  11. echo $des;
  12. echo '<br/>';
  13. }
  14. ?>