Created
September 3, 2014 21:05
-
-
Save ryanhanwu/ea85fa6bba0eeaba45be to your computer and use it in GitHub Desktop.
Scrape web page for coffee shop address
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
var request = require('request'), | |
jsdom = require('jsdom'); | |
request({ | |
uri: 'http://cupsapp.com/' | |
}, function(error, response, body) { | |
if(error && response.statusCode !== 200) { | |
console.log('Error when contacting CUPS Page'); | |
} | |
jsdom.env(body, ['//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'], function(err, window) { | |
var $ = window.jQuery; | |
var addrs = $('h3', '.localate').next('p'); | |
for (var i = addrs.length; i--;) { | |
console.log($('a',addrs[i]).html()); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment