This script imports my Google spreadsheet of books and then pastes them to sell on Amazon books. It takes about 20 seconds to list each book but you only process those in your spreadsheet marked to be re-listed. Example Google Spreadsheet.
Why?
Unless you pay £28.75 per month to Amazon Books to become a professional seller, you don't get the facility to import from a spreadsheet. This iMacro code does exactly that, for free, though it is of course intended for smallish quantities (in practice I'm normally adding less than 6 books at a time and have less than 20 books up for sale). Having recently realized that the handful of books I was trying to sell had not only all expired but had also permanently gone from my closed listings so I had to put them in from scratch, I had the incentive to spend a few hours playing with JavaScript and iMacro to find a decent work around.
Known Bugs
When I have more than 20 books the last ones on the list are ignored as already listed, probably due to export limitations with iMacro. My work around is to list new books at the top of the spreadsheet and it will work fine. You could also cut and paste previously listed books into a second page of the spreadsheet and keep the front page for new books to be listed.
/***************************************************************************** Title: AMAZON BOOK LIST IMPORT FROM GOOGLE SPREADSHEET
Created: 15 May 2008 Last Edit: 17 May 2008 Author: UserOffline.blogspot.com If you find this script useful, blog me back.
Description: This iMacro script reads data from a Google spreadsheet of books and then writes all those (marked as unlisted) to Amazon. Progress is highlighted in a pop-up window. The google spreadsheet has data for: [0] ISBN, [1] Title (for convenience only, not used), [2] Condition, [3] Comments, [4] Price, [5] Listed (Yes/No). This script is particularly handy for managing books taking longer than Amazon's 60 day listing expiry to sell.
Assumptions: 1. Google spreadsheet published and the URL GOTO command below points to it. Note by publishing your spreadsheet, in theory anyone could read it; if they can find it. As there is no personal data apart from the price you set for the books (which is published on your Amazon listing) this creates no privacy risk that I can think of apart from someone associating your Amazon trading name with your Google account name. If you consider this a risk I suggest you create a new (free) Google account for this purpose. 2. You are logged in to your Amazon account. 3. You don't use Firefox while it is running. Note run time is about 25s/book but this includes pauses so you can see what is going on, remove these to save another 5 to 10 seconds. 4. You have iMacro (it's free) installed with Firefox. 5. This script does not remove listings from Amazon, so if you want to change a listing do it by hand or delete the old one and use this script to create it again.
Version History: 17 May Changed ISBN recognition to recognize ASINs as well. ******************************************************************************/
//Define functions
function writeResults(s){top.results.document.write(s)} function showTime(d){ var myS=parseInt((d.valueOf()-startDate.valueOf())/1000); return parseInt(myS/60)+" minutes "+(myS % 60)+" seconds"; } /* Pad number with zeros */ function pad(number, length){ var str=""+number; while(str.length<length){str = "0"+str} return str; } /* Make a string iMacro command compliant */ function safe(str){ return str.replace(/\s/g,"<SP>").replace(/\n/g,"<BR>"); }
//Open progress window
top.results=window.open( "", "myWindow", "menubar=1,resizable=1,status=1,\ width=300,height=450,scrollbars=1,left=10,top=500"); writeResults("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \ \"http://www.w3.org/TR/html4/strict.dtd\">\ <html><head><title>Amazon book lister</title></head>\n\ <body bgcolor=lightyellow>\n\ <font face='Tahoma, Arial' size=1>\n\n");
//Variables
var cr="\n", i, j, startDate=new Date(); var books=new Array(); // 2 dim array for book data var booksHTML=new Array(); // HTML rows from spreadsheet
//Get table of books and extract to booksHTML array
iimPlay("CODE:\ URL GOTO=http://spreadsheets.google.com/pub?\ *Your Google URL to a published spreadsheet goes here*\n\ TAG POS=3 TYPE=TABLE EXTRACT=HTML"); booksHTML=iimGetLastExtract(1).split("<tr"); j=0; for(i in booksHTML){ /* check for ASIN/ISBN of 10+ digits or uppercase letters */ if(booksHTML[i].search(/[\dA-Z]{10}/)>-1){ books[j]=booksHTML[i].split("<td"); j++; } } /* Note - I started off using </td to split the rows, which worked initially but Google appears inconsistent in use of </td> as the next time I used it, the </td> tags were sloppily not included in the web page source. */
//Tidy books array
for(i in books){ /* remove first chopped HTML tag (using "||" as a covenient marker) */ books[i]=books[i].join("||").replace(/\|[^\|<>]*>/g,"|").split("||"); /* drop first two elements as google spreadsheet chaff */ books[i].splice(0,2); /* remove any leftover full HTML tag */ books[i]=books[i].join("||").replace(/<[^><\|]*>/g,"").split("||"); }
//Display and put details on Amazon
for(i in books){ if(books[i][5].search(/No/ig)>-1){ writeResults("<br>"); for(j in Array(0,1,2,3,4)){ writeResults(books[i][j]+"<br>\n"); } iimPlay("CODE:\ URL GOTO=http://www.amazon.co.uk/gp/seller-account/management/your-account.html\n\ TAG POS=1 TYPE=A ATTR=ID:ListSingleItemsLink&&TXT:List<SP>single<SP>items\n\ '** ISBN **\n\ TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:*asin CONTENT="+ books[i][0]+"\n\ WAIT SECONDS=1\n\ TAG POS=1 TYPE=INPUT:IMAGE ATTR=ID:*asin.submit\n\ '** Condition and comments **\n\ TAG POS=1 TYPE=SELECT ATTR=NAME:*condition-type CONTENT=$"+ safe(books[i][2])+"\n\ TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:*condition-comments CONTENT="+ safe(books[i][3])+"\n\ WAIT SECONDS=1\n\ TAG POS=1 TYPE=INPUT:IMAGE\n\ '** Price **\n\ TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:selling-asking-price CONTENT="+ books[i][4].replace(/[^\d\.]/g,"")+"\n\ TAG POS=1 TYPE=INPUT:RADIO ATTR=VALUE:will-ship-to-united-states\n\ WAIT SECONDS=1\n\ TAG POS=1 TYPE=INPUT:IMAGE FORM=ACTION:/exec/varzea/sdp/sai-confirm*\n\ '** Final visual check **\n\ WAIT SECONDS=6\n\ TAG POS=2 TYPE=INPUT:IMAGE FORM=ACTION:/exec/varzea/sdp/sai-thank-you*\n\ "); writeResults("<span style='color:red;font-weight:bold'>[Book "+i+ " now listed on Amazon]</span><br>\n") }else{ writeResults("<span style='color:green'>"+("[Book "+i+ " is already listed]</span>").replace(/\s/g," ")+" \n") } }
//Close down
var endDate=new Date(); writeResults('\n<p>Run time '+showTime(endDate)+"."+cr+ "<br>For more information see <a href='http://useroffline.blogspot.com'>\ UserOffline</a> blog.\n</font>\n</body>\n</html>"); top.results.document.close(); /* Could close when finished with top.results.window.close(); */
No comments:
Post a Comment