Permalink
Browse files

added hackernews example in the readme

  • Loading branch information...
1 parent 13a80d6 commit 82b86b3b62f2f083efd717efaa74c92b115d3d85 @tmpvar committed Feb 18, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 README.md
View
@@ -38,15 +38,21 @@ or with raw html
or with a configuration object
- // Run some jQuery on a html fragment
+ // Print all of the news items on hackernews
var jsdom = require('jsdom');
jsdom.env('http://news.ycombinator.com/', [
'http://code.jquery.com/jquery-1.5.min.js'
], function(errors, window) {
- $()
+ var $ = window.$;
+
+ console.log('HN Links');
+ $('td.title:not(:last) a').each(function() {
+ console.log(' -', $(this).text());
+ });
});
+
### How it works
`jsdom.env` is built for ease of use, which is rare in the world of the DOM! Since the web has some absolutely horrible javascript on it, as of jsdom 0.2.0 `jsdom.env` will not process external resources (scripts, images, etc). If you want to process the javascript use one of the methods below (`jsdom.jsdom` or `jsdom.jQueryify`)

0 comments on commit 82b86b3

Please sign in to comment.