-
-
Save mortenjust/2066779 to your computer and use it in GitHub Desktop.
Scraping with jsdom and jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://github.com/tmpvar/jsdom/tree/master/lib | |
$ curl http://www.timeanddate.com/norsk/kalender.html | |
(...) | |
<div id=po1 class=po></div> | |
<h1>Kalender for år 2011</h1> | |
<table class="ct" border="0" cellpadding="4" cellspacing="0" align="center"> | |
(...) | |
$ node scrape.js | |
This is 2011 | |
*/ | |
var jsdom = require("jsdom"); | |
var url = 'http://www.timeanddate.com/norsk/kalender.html'; | |
jsdom.env(url, [ 'http://code.jquery.com/jquery-1.7.min.js' ], done); | |
function done (errors, window) { | |
var year = window.$('h1').text().replace(/[^\d]/g, ''); | |
console.log('This is', year); | |
window.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment