#!/usr/bin/perl # circle_rss.pl # Author: Paul Bausch # # Accepts a purchase circle ID, contacts Amazon for data, and produces an RSS feed. # Purchase circles? http://www.amazon.com/exec/obidos/subst/community/community.html # Purchase circle ID? -- pick a circle and look for the ~6 digit number in the URL. use strict; use LWP::Simple; #Take the query from the command-line my $circle_id = shift @ARGV or die "Usage:perl circle_rss.pl \n"; #Assemble the URL my $url = "http://www.amazon.com/exec/obidos/tg/cm/community-data/-/" . $circle_id . "/book/B/"; #Request page my $content = get($url); die "Could not retrieve $url" unless $content; #Turn contents into array my @data = split(/"$circle_id",/,$content); #Initialize some variables my($Asin,$title,$author,$aurl,$publisher); #Print RSS Header print < Amazon.com - Purchase Circles http://www.amazon.com/exec/obidos/tg/browse/-/45/1/?rank=%2Bsalesrank%26dev-t=amznRss Listings of Amazon.com's purchase circles. en-us http://www.amazon.com/exec/obidos/subst/xs/syndicate.html Amazon.com--Earth's Biggest Selection http://images.amazon.com/images/G/01/rcm/logo2.gif 120 30 http://www.amazon.com RSS_HEADER #Loop through array foreach my $row (@data) { #print $row . "\n\n"; my @value = split(/",/,$row); $Asin = $value[1]; $title = $value[2]; $title =~ s!"!!g; #remove quotes $author = $value[3]; $author =~ s!"!!g; #remove quotes $author =~ s!é!‚!g; #convert e acute accent $aurl = $value[4]; $aurl =~ s!"!!g; #remove quotes $publisher = $value[5]; if (!$title eq '') { print "\n", " $title\n", " $aurl\n", " $title by $author\n", "\n"; } } #Print RSS Footer print < RSS_FOOTER