php 解析rss代码一段
发布时间:2022-01-18 23:27:09 所属栏目:PHP教程 来源:互联网
导读:?php function my_headlines($url) { $rdf = parse_url($url); $fp = fsockopen($rdf[host], 80, $errno, $errstr, 15); if (!$fp) { $content = font class=contentProblema!/font; return; } if ($fp) { fputs($fp, GET . $rdf[path] . ? . $rdf[query]
<?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 ?> (编辑:武汉站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |