Library tech blog

Thoughts and ideas on technology

Using Sirsi API to get ISBN numbers

The goal here is to extract all the books that where cataloged yesterday and get there ISBN numbers. To then sort these and only take the uniq numbers. I then  plan to use these numbers and amazon webservices and get some interesting information then create virtual library cards. I just about have all the pieces in place. One of the things that I an still thinking about catagories and access. At the moment I am thinking that I will transfer the isbn file to another machine and then use mysql, perl and php to do the mashing that I want.
Here is the code I used to do this

#!//bin/perl

open(MYFILE, qq#/s/sirsi/Unicorn/Bin/selitem -tBOOK -f=20051010 -oC | /s/sirsi/Unicorn/Bin/selcatalog -iC -oe -e020|sort|uniq|#);

while (<MYFILE>) {
$mystring=substr($_,0,10);
if ( length($mystring) == 10){
print $mystring . “\n”;
}

}

October 13, 2006 Posted by tscrobinson | Uncategorized | | 1 Comment

Playing with Amazon’s Web Services and Perl

Well here is some code that I adapted. It goes out and hits the Amazon Webservice and does a keyword search. It is my first go at using the service. I plan to combind this with the library card code below along with some code I need to write to display books we have entered into the catalog. The Data:Dumper was just me taking a look at the xml layout and trying to figure things out.

#####################################################################
# testaws-2.pl
# I have taken a typical script to access the Amazon webservices and made some
# adpaptions to it.
# Usage: testaws-2.pl <keyword>
#
#####################################################################
#Your Amazon developer’s token
my $dev_key=’insert developer’s token ‘;

#Your Amazon affiliate code
my $af_tag=’insert associate tag’;

#Take the keyword from the command-line
my $keyword =shift @ARGV or die “Usage:perl testaws-2.pl <keyword>\n”;

#Assemble the URL
my $url = “http://xml.amazon.com/onca/xml3?t=” . $af_tag .
“&dev-t=” . $dev_key .
“&type=lite&f=xml&mode=books&” .
“KeywordSearch=” . $keyword;

use strict;

#Use the XML::Parser  and LWP::Simple Perl modules
use XML::Simple;
use LWP::Simple;
use Data::Dumper;
my $content = get($url);
#print $content;
die “Could not retrieve $url” unless $content;

my $xmlsimple = XML::Simple->new( );
my $response = $xmlsimple->XMLin($content);
print Dumper($response);

foreach my $result (@{$response->{Details}}){
#Print out the main bits of each result

join “\n”,
print $result->{ProductName} .  “\n” ||”no title,\n”;
if (eval {$result->{Authors}->{Author}->[0] }){
for (my $i =0; $result->{Authors}->{Author}->[$i]; $i++){
print “Author: ” . $result->{Authors}->{Author}->[$i] . “\n”;
}
}
else {
print “Author: ” . $result->{Authors}->{Author}. “\n” ;
}

print “ASIN: ” . $result->{Asin} . “, ” ;
print $result->{OurPrice} . “\n\n”;
}

October 10, 2006 Posted by tscrobinson | Uncategorized | | No Comments Yet