node.js/coffeescript で、jQueryを使ってスクレイピング

chreerioもあるようですが、jQueryのtraverse機能を使いたかったので
jsdom + jqueryスクレイピングしたものを操作します。

request = require 'request'
jsdom = require 'jsdom'
jquery = 'http://code.jquery.com/jquery-1.8.0.js'

RequestObj = 
	uri: 'http://www.google.com'
	method: 'GET'
	encoding: null
	headers:
	  'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)'

scrapeBy$ = (err, window) ->
	$ = window.jQuery
        console.log $('title').html()
	window.close()

htmlHandler = (err, res, body) ->
	jsdom.env
            html: body
	    scripts: [jquery, ]
	, scrapeBy$

RequestObj.uri = url
request RequestObj, htmlHandler