|
LOKALE KLEINANZEIGEN
function text_kuerzen($string, $length)
{
if(strlen($string) >= $length) $string = trim(substr($string, 0, $length))." [...]";
return $string;
}
function rss($url,$number)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$str = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($str);
$c=0;
foreach ($xml->channel->item as $item)
{
$link = $item->link;
$title = $item->title;
// $title = utf8_decode($title);
$datum = date("j.m.Y",strtotime($item->pubDate));
// Definiere Description
if($item->description != "")
{
// RSS
$encoded = $item->description;
}
else
{
// RSS2
$keks = $item->children('http://purl.org/rss/1.0/modules/content/');
$encoded = (string) $keks->encoded;
}
// Wenn Descrption nicht angegeben
if($encoded == "")
{
$encoded = "Kein Beschreibungstext";
}
// Definiere Enclosure
if($item->enclosure != "")
{
// RSS
$image = " ";
}
$text = $encoded;
$text = strip_tags($text,'![]() ');
// $text = utf8_decode($text);
$text = text_kuerzen($text,300);
echo ' '.$text.'';
$c++;
if ( $c >= $number) break;
}
}
echo rss('http://kleinanzeigen.ebay.de/anzeigen/s-feed.rss?adType=OFFER&locationId=2131',5);
?>
|
|