The Code
This Perl script,
get_friend_IDs.pl,
uses an Amazon ID, grabs the HTML of the
Friends list, and finds
your friends' Amazon IDs.
#!/usr/bin/perl
# get_friend_IDs.pl
# A script to scrape Amazon, retrieve friend IDs, and write to a file
# Usage: perl get_friend_IDs.pl <amazonID>
#Take the asin from the command-line
my $amazonID =shift @ARGV or die "Usage:get_friend_IDs.pl <amazonID>\n";
#Assemble the URL
my $url = "http://amazon.com/exec/obidos/tg/cm/member-favorites/-/" .
$amazonID . "/";
use strict;
use LWP::Simple;
#Request the URL
my $content = get($url);
die "Could not retrieve $url" unless $content;
my $friends = (join '', $content);
while ($friends =~ m!<b><a href="/exec/obidos/tg/cm/member-glance/-/(.*?)/&return;
ref=cm_aya_av.fp_faya/">(.*?)</a></b>!mgis) {
my($amznID,$name) = ($1||'',$2||'');
#Print the results
print $name . " (" .
$amznID . ")" .
"\n\n";
}