查看完整版本: [-- php 分析rss代码一段 --]

.::: 一路问情 :::. -> 『PHPBlast』 -> php 分析rss代码一段 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

fuckxy 2008-05-24 09:41

function my_headlines($url) {
$rdf = parse_url($url);
$fp = fsockopen($rdf['host'], 80, $errno, $errstr, 15);
if (!$fp) {
$content = "Problema!";
return;
}
if ($fp) {
fputs($fp, "GET " . $rdf['path'] . "?" . $rdf['query'] . " HTTP/1.0/r/n");
fputs($fp, "HOST: " . $rdf['host'] . "/r/n/r/n");
$string = "";
while(!feof($fp)) {
$pagetext = fgets($fp,300);
$string .= chop($pagetext);
}
fputs($fp,"Connection: close/r/n/r/n");
fclose($fp);
$items = explode("",$string);
$content = "";
for ($i=0;$i<10;$i++) {
$link = ereg_replace(".*","",$items[$i]);
$link = ereg_replace(".*","",$link);
$title2 = ereg_replace(".*","",$items[$i]); <br> $title2 = ereg_replace(".*","",$title2);
if ($items[$i] == "") {
$content = "";
return;
} else {
if (strcmp($link,$title)) {
$cont = 1;
$content .= "$title2
/n";
}
}
}
}
echo "$content";
}

my_headlines
?>


查看完整版本: [-- php 分析rss代码一段 --] [-- top --]



Powered by PHPWind v6.3.2 Code © 2003-08 PHPWind
Time 0.032872 second(s),query:3 Gzip enabled

You can contact us