Home > php教程 > php手册 > php 分析rss代码一段

php 分析rss代码一段

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-02 09:14:34
Original
1311 people have browsed it

<?php
function my_headlines($url) {
    $rdf = parse_url($url);
    $fp = fsockopen($rdf[&#39;host&#39;], 80, $errno, $errstr, 15);
    if (!$fp) {
        $content = "<font class=\"content\">Problema!</font>";
        return;
    }
    if ($fp) {
        fputs($fp, "GET " . $rdf[&#39;path&#39;] . "?" . $rdf[&#39;query&#39;] . " HTTP/1.0 ");
        fputs($fp, "HOST: " . $rdf[&#39;host&#39;] . " ");
        $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\" alt="php 分析rss代码一段 " ><a href=\"$link\" target=\"new\">$title2</a><br> ";
                }
            }
        }
    }
    echo "$content";
}
my_headlines();
Copy after login


文章链接:

随便收藏,请保留本文地址!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template