<?php
$url = 'https://liputan24.net/?s=banjarbaru&feed=rss2';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$res = curl_exec($ch);

$rss_content = preg_replace('/xmlns[^=]*="[^"]*"/i', '', $res);
$rss = @simplexml_load_string($rss_content, 'SimpleXMLElement', LIBXML_NOCDATA);

foreach ($rss->channel->item as $item) {
    $judul = isset($item->title) ? strip_tags((string)$item->title) : '';
    $link = isset($item->link['href']) ? (string)$item->link['href'] : (string)$item->link;
    $raw_desc = isset($item->description) ? (string)$item->description : ((string)$item->content ?: (string)$item->summary);
    $tanggal = isset($item->pubDate) ? (string)$item->pubDate : ((string)$item->published ?: (string)$item->updated);
    
    echo "Judul: " . substr($judul, 0, 60) . "\n";
    echo "Link: " . $link . "\n";
    echo "Tgl : " . $tanggal . " -> " . date('Y-m-d H:i:s', strtotime($tanggal)) . "\n\n";
}
