Skip to content

Instantly share code, notes, and snippets.

@irace
Created October 3, 2012 18:29
Show Gist options
  • Save irace/3828834 to your computer and use it in GitHub Desktop.
Save irace/3828834 to your computer and use it in GitHub Desktop.
Basic Node.js screen-scraping
var express = require('express')
, app = express()
, jsdom = require('jsdom');
app.set('views', __dirname);
app.get('/', function(request, response) {
jsdom.env({
html: 'http://bryanirace.com',
scripts: ['http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.0/jquery.min.js'],
done: function (errors, window) {
var $ = window.$;
response.render('index.jade', {
scrapedData: $('div.foo').text()
});
}
});
});
app.listen(4000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment