Friday, December 30, 2011

Book Search

I buy quite a few Christian books. One chore I thought needed automating was searching the half-a-dozen British Christian book websites to see which have the book and which is cheapest. I couldn't find an easy work around, so I scripted one. My JS skills aren't what they should be, but this seems to work.

<html>
<head>
<script type="text/javascript">
function dosearch() {
var sites=new Array();
sites[1]="http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=";
sites[2]="http://www.eden.co.uk/shop/search.php?category_id=&keyword=";
sites[3]="http://www.wesleyowen.com/search/product/productPowerSearch.jhtml?keywords=";
sites[4]="http://www.bookdepository.co.uk/search?searchTerm=";
sites[5]="http://www.10ofthose.com/search/?query=";
var n=1;
for (n=1;n<=5;n++)
{
var fulladd = sites[n]+ escape(document.searchform.searchterms.value);
window.open(fulladd);
}
}
</script>
<style type="text/css">
p {
font: 12pt Arial;
margin-left: 2cm;
margin-top: 1cm;
}
form {
margin-left: 3cm;
width: 10cm;
padding: 1cm;
}
</style>
<title>John's Christian Book Search</title>
</head>
<body>
<p>Please enter the name of the book you want to find in the box below, and then press "Search".</p>
<form name="searchform" onSubmit="return dosearch();">
<input type="text" name="searchterms">
<input type="submit" name="SearchSubmit" value="Search">
</form>
</body>
</html>

To use: copy and paste that into a text editor. Save it as "books.htm", and it should work. Any title you type into the box should result in you getting five windows/tabs, one for each of the online bookshops I use most often. Feel free to modify the code, redistribute and so on - it can be easily modified to work for any other searching. Just don't charge for it! If you want a copy of the html file, feel free to e-mail me and I'll send you one.

1 comment:

Murray said...

I also use www.bookfinder.com - sorts everything one one page, but probably doesn't include all the Christian retailers.