sushsen has asked for the wisdom of the Perl Monks concerning the following question:

Hi, i am new to perl and have been placed on a project were i need to write a perl script that is supposed grab rss feeds from different vulnerabilities sites and then parse that info while segregating it by cve details, scores, platform etc. and then finally saving it in a CSV file. any help would be greatly appreciated. i have java programming experience and a little bit of python. Thanks a lot

Replies are listed 'Best First'.
Re: RSS feed grabber
by tangent (Parson) on Jul 21, 2015 at 15:09 UTC
    Have a look at LWP::Simple, XML::RSS and Text::CSV

    Quick start:

    use LWP::Simple; use XML::RSS; while ( my $url = <DATA>) { chomp $url; my $xml = get( $url ) or next; my $rss = XML::RSS->new; eval { $rss->parse( $xml ) }; next if $@; for my $item ( @{ $rss->{'items'} } ) { # do stuff with $item } } __DATA__ http://example.com/feed.rss http://example2.com/feed.rdf http://example3.com/feed.xml
Re: RSS feed grabber
by stevieb (Canon) on Jul 21, 2015 at 14:40 UTC

    Welcome to the Monastery!

    We also have projects to do, so we don't have time to up and write full blown scripts for people to complete their projects (especially when you're getting paid for it and we aren't).

    What we will do is help guide you towards a solution after you can show that you've made some attempt (by posting your code) and explaining where exactly you're stuck.

      no absolutely. i was looking for tips on where to get started or some directional advice.
Re: RSS feed grabber
by neilwatson (Priest) on Jul 21, 2015 at 16:41 UTC

    Here's a working sub from a chat bot of mine (UPDATE: some cleanup for OP):

    =pod Usage: atom_feed({ feed => 'https://example.com/feed.atom', newer_than => 1440 }); =cut sub atom_feed { my ( $arg ) = @_; my $feed = $arg->{feed}; my $newer_than = exists $arg->{newer_than} ? $arg->{newer_than} : $c->{newer_than}; my @events; warn "Getting atom feed for [$feed] ". "records newer than [$newer_than]min" if $args->{debug}; my $returned_xml = XML::Feed->parse( URI->new( $feed )) or die "Feed error with [$feed] ".XML::Feed->errstr; for my $next_entry ( $returned_xml->entries ) { warn "Got bug title [$next_entry->{title}]" if $args->{debug}; # Get only entries of a specific title and age. if ( $next_entry->title =~ m/\A\w+ # Start \s+ \#\d{4,5} # bug numb +er \s+ \( (Open|Closed|Merged|Rejected|Unconfirmed) \) # Status o +f bug /ix and time_compare({ time => $next_entry->updated, newer_than => $newer_than }) ) { push @events, qq{$next_entry->title, $next_entry->link}; } } say $_ foreach ( @events ); return \@events; }
    From here

    Neil Watson
    watson-wilson.ca

      not sure how this is supposed to grab the rss feeds. im trying to understand the logic behind this sub routine. Thanks