Forum Moderators: coopster & phranque

Message Too Old, No Replies

How do you get content from another site (RSS)?

         

Jesse_Smith

5:45 pm on Sep 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How do you get a script to get the content from another site (rss) and then place it on the page where you place for example

$rss

Jesse_Smith

6:01 pm on Sep 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try one of these codes!

******

#!/usr/bin/perl
use LWP::Simple;
#Store the output of the web page (html and all) in content
my $content = get("http://www.url.com");
if (defined $content)
{
#$content will contain the html associated with the url mentioned above.
print $content;
}
else
{
#If an error occurs then $content will not be defined.
print "Error: Get failed";
}

******

#!/usr/bin/perl
use LWP::Simple;

print "Content-Type: text/html\n\n\n";

my $content = get("http://www.url.org");
print $content;

open (OUT,">output.text");
print OUT $content;
close OUT;

__END__

*******

#!/usr/bin/perl

use lib '/var/www/cgi-bin/libwww-perl-5.65/lib';
use LWP::Simple;

$content = get ('http://www.url.com');

print "Content-type: text/html\n\n";
print "$content";

******

Google rocks!

BananaFish

11:43 pm on Sep 22, 2005 (gmt 0)

10+ Year Member



You would also need to parse the xml with something like XML::Simple

SeanW

12:14 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



You can use LWP or Mech to get the feed as others have shown.

I'd suggest XML::RSS to parse it. Though XML::Simple will do it, there are several forms of RSS and it's far easier to get the data from XML:RSS than it would be to parse the hash tree than XML::Simple gives you.

Sean