use zUtil;

sub seekingalpha_rss
{
   $html = shift;
   my( @rValue ) = ();
   my ( $title, $url, $date );

   $html =~ s/&amp;/&/gixs;

   while( $html =~ s/<item>.*?<title>(.*?)<\/title>.*?<link>(.*?)<\/link>.*?<pubDate>(.*?)<\/pubDate>.*?<\/item>//six )
   {
       $title = $1;
       $url = $2;
       $date = $3;

       # Clean up title
       $title =~ s/<!\[CDATA\[//gsi;
       $title =~ s/\]\]>//gsi;

       next if $title =~ /^\s*$/;

       # Simplify date (e.g., "Fri, 26 Dec 2025 09:41:53 -0500" -> "Dec 26")
       my $shortdate = "";
       if ($date =~ /(\w+),\s+(\d+)\s+(\w+)\s+(\d+)/) {
           $shortdate = "$3 $2";
       }

       push @rValue, {
           'headline' => $title,
           'url'      => $url,
           'date'     => $shortdate,
       };

       undef($url);
       undef($title);
       undef($date);
   }

   return @rValue;
}

1;
