dans la totalité et filtré par catégories
En attendant pour palier au manque;
un code à placer dans un fichier php sur un site perso, qui s'utilise avec en parametre la catégorie
monsite.fr/xxx/nautiljon_rss.php?cat=ost
monsite.fr/xxx/nautiljon_rss.php?cat=jmusic
etc....
avec dans nautiljon_rss.php le code
<?
// This program is public domain. Do with this what you want.
// It is derived from Gnews2rss (http://www.voidstar.com/gnews2rss.php )
// by Barijaona Ramaholimihaso
// -------------------------------------------------- --------------------------
// URL to parse
$url = "http://www.nautiljon.com/".$_GET['cat'];;
// do not scrap before this text
$ignore_before = "<table id=\"dernier_ajouts\" >";
// encoding
$encoding = "iso-8859-1";
// description
// language
$channel_language = "fr-fr";
// regular expression pattern, and positions
// of interesting stuff delimited by parenthesis in the pattern
$itemregexp = "/a[\s]+[^>]*?href[\s]?=[\s\"\']+(.*?)[\"\']+.*?>([^<]+|.*?)?<\/a>/";
$url_match_number = 1;
$title_match_number = 2;
$desc_match_number = 3;
// This is used to suppress some tags and makes writing the search pattern easier
$searchable_tags = "<A><B><BR><BLOCKQUOTE><CENTER><DD><DL><DT><HR><I> <IMG><LI><OL><P><PRE><U><UL>";
//------------------------------------------------ -- ----------------------------
$allowable_tags = "<A><B><BR><BLOCKQUOTE><CENTER><DD><DL><DT><HR><I> <IMG><LI><OL><P><PRE><U><UL>";
header("Cache-Control: public");
header("Content-Type: text/xml");
preg_match("/(http:\/\/([^\/]*))/i", $url, $matches);
$root = $matches[1]."/";
if ($fp = @fopen($url, "r")) {
while (!feof($fp)) $data .= fgets($fp, 128);
fclose($fp);
}
// *******************
eregi("<title>(.*)</title>", $data, $title);
$channel_title = $title[1];
$channel_description = "Nautiljon ".$title[1];
// trash the text before the $ignore_before text
$data = strstr($data,$ignore_before);
// suppress some tags and makes writing the search pattern easier
$data = strip_tags($data, $searchable_tags);
$match_count = preg_match_all($itemregexp, $data, $items);
$match_count = ($match_count > 70) ? 70 : $match_count;
$output .= "<?xml version=\"1.0\" encoding=\"$encoding\" ?>\n";
$output .= "<!DOCTYPE rss >\n";
$output .= "<rss version=\"2.0\">\n";
$output .= " <channel>\n";
$output .= " <title>$channel_title</title>\n";
$output .= " <link>". htmlentities($url) ."</link>\n";
$output .= " <description>$channel_description</description>\n" ;
$output .= " <language>$channel_language</language>\n";
$output .= " <generator>ssjgotrunk</generator>\n";
for ($i=0; $i< $match_count-1; $i++) {
$item_url = $items[$url_match_number][$i];
$item_url = htmlspecialchars($item_url, ENT_QUOTES, $encoding);
$item_url = preg_replace("%^/%", $root, $item_url);
$title = $items[$title_match_number][$i];
$title = strip_tags($title);
$title = htmlspecialchars(html_entity_decode($title, ENT_QUOTES, $encoding), ENT_QUOTES, $encoding);
$title = preg_replace("/([0-9]+);/", "\${1};", $title);
$desc = $items[$desc_match_number][$i];
$desc = strip_tags($desc, $allowable_tags);
$desc = htmlspecialchars(html_entity_decode($desc, ENT_QUOTES, $encoding), ENT_QUOTES, $encoding);
$desc = preg_replace("/([0-9]+);/", "\${1};", $desc);
if(strcmp($title,"")!=0){
$output .= " <item>\n";
$output .= " <title>". $title ."</title>\n";
$output .= " <link>". $item_url ."</link>\n";
$output .= " <description>". $desc ."</description>\n";
$output .= " </item>\n";
}
}
$output .= " </channel>\n";
$output .= "</rss>\n";
print $output;
?>
// This program is public domain. Do with this what you want.
// It is derived from Gnews2rss (http://www.voidstar.com/gnews2rss.php )
// by Barijaona Ramaholimihaso
// -------------------------------------------------- --------------------------
// URL to parse
$url = "http://www.nautiljon.com/".$_GET['cat'];;
// do not scrap before this text
$ignore_before = "<table id=\"dernier_ajouts\" >";
// encoding
$encoding = "iso-8859-1";
// description
// language
$channel_language = "fr-fr";
// regular expression pattern, and positions
// of interesting stuff delimited by parenthesis in the pattern
$itemregexp = "/a[\s]+[^>]*?href[\s]?=[\s\"\']+(.*?)[\"\']+.*?>([^<]+|.*?)?<\/a>/";
$url_match_number = 1;
$title_match_number = 2;
$desc_match_number = 3;
// This is used to suppress some tags and makes writing the search pattern easier
$searchable_tags = "<A><B><BR><BLOCKQUOTE><CENTER><DD><DL><DT><HR><I> <IMG><LI><OL><P><PRE><U><UL>";
//------------------------------------------------ -- ----------------------------
$allowable_tags = "<A><B><BR><BLOCKQUOTE><CENTER><DD><DL><DT><HR><I> <IMG><LI><OL><P><PRE><U><UL>";
header("Cache-Control: public");
header("Content-Type: text/xml");
preg_match("/(http:\/\/([^\/]*))/i", $url, $matches);
$root = $matches[1]."/";
if ($fp = @fopen($url, "r")) {
while (!feof($fp)) $data .= fgets($fp, 128);
fclose($fp);
}
// *******************
eregi("<title>(.*)</title>", $data, $title);
$channel_title = $title[1];
$channel_description = "Nautiljon ".$title[1];
// trash the text before the $ignore_before text
$data = strstr($data,$ignore_before);
// suppress some tags and makes writing the search pattern easier
$data = strip_tags($data, $searchable_tags);
$match_count = preg_match_all($itemregexp, $data, $items);
$match_count = ($match_count > 70) ? 70 : $match_count;
$output .= "<?xml version=\"1.0\" encoding=\"$encoding\" ?>\n";
$output .= "<!DOCTYPE rss >\n";
$output .= "<rss version=\"2.0\">\n";
$output .= " <channel>\n";
$output .= " <title>$channel_title</title>\n";
$output .= " <link>". htmlentities($url) ."</link>\n";
$output .= " <description>$channel_description</description>\n" ;
$output .= " <language>$channel_language</language>\n";
$output .= " <generator>ssjgotrunk</generator>\n";
for ($i=0; $i< $match_count-1; $i++) {
$item_url = $items[$url_match_number][$i];
$item_url = htmlspecialchars($item_url, ENT_QUOTES, $encoding);
$item_url = preg_replace("%^/%", $root, $item_url);
$title = $items[$title_match_number][$i];
$title = strip_tags($title);
$title = htmlspecialchars(html_entity_decode($title, ENT_QUOTES, $encoding), ENT_QUOTES, $encoding);
$title = preg_replace("/([0-9]+);/", "\${1};", $title);
$desc = $items[$desc_match_number][$i];
$desc = strip_tags($desc, $allowable_tags);
$desc = htmlspecialchars(html_entity_decode($desc, ENT_QUOTES, $encoding), ENT_QUOTES, $encoding);
$desc = preg_replace("/([0-9]+);/", "\${1};", $desc);
if(strcmp($title,"")!=0){
$output .= " <item>\n";
$output .= " <title>". $title ."</title>\n";
$output .= " <link>". $item_url ."</link>\n";
$output .= " <description>". $desc ."</description>\n";
$output .= " </item>\n";
}
}
$output .= " </channel>\n";
$output .= "</rss>\n";
print $output;
?>
(Edité 1 fois. Dernière édition par ssjgotrunk le 23/06/2007 à 09:50)









