Bic cameraをスクレイピング

私用めも

#!/usr/bin/env node

'use strict';  
var casper = require('casper').create();

casper.options.waitTimeout = 1000;  
casper.start();  
casper.viewport(1440,900);

function getDetail() {  
    var detail = document.querySelectorAll("#detailBox dl");
    return Array.prototype.map.call(detail, function(e) {
        return {
          label: e.children[0].innerText,
          arg: e.children[1].innerText
        };
    });
}

casper.open("http://www.biccamera.com/bc/disp/CSfGoodsPage_001.jsp?GOODS_NO=3275749");  
casper.then(function(){  
  var price = this.evaluate(getDetail);
  price.forEach(function(i,val){
    casper.echo(i.label + " - " + i.arg);
  });
});

casper.run();  

coffee版もおいておく

#!/usr/bin/env node

'use strict'

getDetail = ->  
  detail = document.querySelectorAll('#detailBox dl')
  Array::map.call detail, (e) ->
    {
      label: e.children[0].innerText
      arg: e.children[1].innerText
    }

casper = require('casper').create()  
casper.options.waitTimeout = 1000  
casper.start()  
casper.viewport 1440, 900  
casper.open 'http://www.biccamera.com/bc/disp/CSfGoodsPage_001.jsp?GOODS_NO=3275749'  
casper.then ->  
  price = @evaluate(getDetail)
  price.forEach (i, val) ->
    casper.echo i.label + ' - ' + i.arg
    return
  return
casper.run()