Skip to content

Instantly share code, notes, and snippets.

@mizchi
Created August 8, 2011 22:48
Show Gist options
  • Save mizchi/1132947 to your computer and use it in GitHub Desktop.
Save mizchi/1132947 to your computer and use it in GitHub Desktop.
スクレイピングのひな形
request = require('request')
jsdom = require('jsdom').jsdom;
jquery = require('jquery')
fs = require 'fs'
fetch = (uri,fn)->
request uri:uri, (error, response, body)->
fn error,jquery.create jsdom(body).createWindow()
save = (path)->
fname = path.split('/').pop()
request uri:path,encoding:'binary', (error, response, body)->
fs.writeFile fname, body, 'binary', (err)->
console.log 'save: '+fname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment