NodejsでspookyJSを使ってFBA手数料を取得する

#注意
自分用メモです。コードの解説はしていません。

#コード
```spooky_sample.js
'use strict';

const asin = "B012345678"; 
const price = 2000;

try {
    var Spooky = require('spooky');
} catch (e) {
    Spooky = require('../lib/spooky');
}

var spooky = new Spooky({
    child: { transport: 'http' },
    casper: {
        logLevel: 'debug',
        verbose: true
    }
},
                        function (err) {
                            if (err) { throw new Error('spooky起動エラー'); }
                            spooky.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36 ');
                            var FBA_url = "https://sellercentral-japan.amazon.com/fba/profitabilitycalculator/index?lang=ja_JP&asin=" 
 + asin + "&price=" + price;
                            spooky.start(FBA_url);

                            spooky.then(function () {
                                this.evaluate(function(){                                  
                                    document.getElementById('search-string').value = new String(window.location.href).match(/B0[0-Z]{8}/)[0];
                                    document.getElementsByClassName('a-button-input')[0].click();
                                });
                            });

                            spooky.wait(1000,function(){
                                this.evaluate(function(){                                        
                                    document.getElementById('afn-pricing').value = new String(window.location.href).match(/price=[0-9]+/)[0].replace(/price=/,'');
                                    document.getElementById('update-fees-link').click();
                                });
                            });

                            spooky.wait(2000,function(){
                                var result = this.evaluate(function(){
                                    document.getElementById('afn-amazon-fulfillment-fees').click();
                                    return {
                                        asin : new String(window.location.href).match(/B0[0-Z]{8}/)[0],
                                        length : document.getElementById('product-info-length').innerText,
                                        width : document.getElementById('product-info-width').innerText,
                                        height : document.getElementById('product-info-height').innerText,
                                        weight : document.getElementById('product-info-weight').innerText,
                                        categoryCost : document.getElementById('afn-selling-fees').innerText,
                                        packegeCost : document.getElementById('afn-weight-handling-fee').value,
                                        totalCost : new Number(document.getElementById('afn-pricing').value) - new Number(document.getElementById('afn-seller-proceeds').value)
                                    };
                                });
                                this.emit('hello',result);
                            });

                            spooky.run();
                        });


spooky.on('error', function (e, stack) {
    console.log(e);
});

spooky.on('hello', function (rate) {
    //return rate;    
    console.log(rate);
});

spooky.on('log', function (log) {
    if (log.space === 'remote') {
        console.log(log.message.replace(/ \- .*/, ''));
    }
});