I remember someone asking for an ISBN lookup for the Great Perl Booke Exchange, and came across this script. It uses Amazon's website for the service, and I acknowledge that some may feel ethically compelled to not use this script. I found that in testing it, the parse_amazon sub doesn't exactly function as advertised; some of the page's html has been altered slightly. below is a corrected version :
sub parse_amazon { my ( $text, $ashash ) = @_; return undef if $text =~ /Books search: we were unable to find exa +ct matches/i; my ( $title ) = $text =~ /^Amazon.com: buying info: (.*)$/im; my ( $pages ) = $text =~ m:(\d+) pages:; my ( $price ) = $text =~ m:<strike>\$([\d\.]+)</strike>:; my ( $publisher ) = $text =~ m:\n\s+([^;\n]+);[\s\n]+ISBN:isg; my ( $author ) = $text =~ m:\nby <a href=[^>]+>(.*?)</font>:s; $author =~ s/<.*?>//sg; $author =~ s/\([^\)]+\)//g; chomp $author; my @authors = split /\s*,\s*/,$author; $"=", "; chomp @authors; # +" return "$title\n by @authors\n $pages pages, \$$price\n $publisher +\n" unless $ashash; return { title => $title, author => $authors[0], author2 => $autho +rs[1], author3 => $authors[2], pages => $pages, price => $price*$DOLLAR, publisher => $ +publisher } }
The script will output one of two things -- formatted text :
Perl 5 Pocket Reference, 3rd Edition: Programming Tools (O'Reilly Perl +) by Johan Vromans, Larry Wall, Linda Mui 96 pages, $9.95
or a hash
(title => "Perl 5 Pocket Reference, 3rd Edition: Programming Tools", author1=> "Johan Vromans", author2=> "Larry Wall", author3=> "Linda Mui", pages => 96, price => "$9.95", publisher => "O'Reilly Perl")

Replies are listed 'Best First'.
Re: ISBN lookup via Amazon
by turnstep (Parson) on Feb 28, 2001 at 05:41 UTC

    Even if you dislike Amazon, why not use this script (and tax their servers, if ever so slightly) and then actually buy your books from Fatbrain (and go through the Buy Stuff page to do so of course)