加入收藏 | 设为首页 | 会员中心 | 我要投稿 汽车网 (https://www.0577qiche.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php 分析rss代码一段

发布时间:2023-05-27 14:00:51 所属栏目:PHP教程 来源:
导读:php 分析rss代码一段

<?php
function my_headlines($url) {
$rdf = parse_url($url);
$fp = fsockopen($rdf[&#39;host&#39;], 80, $errno, $errstr, 15);
if (!$fp) {
$content
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 "); 
     fputs($fp, "HOST: " . $rdf['host'] . " "); 
     $string = ""; 
     while(!feof($fp)) { 
     $pagetext = fgets($fp,300); 
     $string .= chop($pagetext); 
 } 
 fputs($fp,"Connection: close "); 
 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> "; 
    } 
     } 
 } 
      } 
      echo "$content"; 

my_headlines 
?> 

(编辑:汽车网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章