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

I want to read the RSS feeds from the web site say, http://www.traffic.com/feeds/rss_atlanta.xml I know little about socket programming. I tried to get it by using socket and HTTP GET request, but here what I get is the source code of that web page but I want the content of the web page, e.g for the above link I want to get xml file shown on that web page. I will really apprecite the reply. thanks.

Replies are listed 'Best First'.
Re: Accessing RSS feeds using perl
by fmerges (Chaplain) on Aug 06, 2005 at 02:13 UTC

    Hi,

    For example:

    #!/usr/bin/perl use warnings; use strict; use XML::RSS; use LWP::Simple; # Get the source file my $source = get("http://www.traffic.com/feeds/rss_atlanta.xml"); # Create a new XML:RSS object my $rss = new XML::RSS (version => '2.0'); # Parse the file into the XML::RSS object $rss->parse($source); # For example print titles and links of each RSS item foreach my $item (@{$rss->{'items'}}) { print "title: $item->{'title'}\n"; print "link: $item->{'link'}\n\n"; }

    Regards,

    |fire| at irc.freenode.net
Re: Accessing RSS feeds using perl
by davidrw (Prior) on Aug 06, 2005 at 00:03 UTC
    GET'ing the page should work just fine .. LWP::Simple makes this, well, simple ;)
    perl -MLWP::Simple -e 'getprint "http://www.traffic.com/feeds/rss_atla +nta.xml"'