Skip to content

Instantly share code, notes, and snippets.

@ryanhanwu
Created September 3, 2014 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanhanwu/ea85fa6bba0eeaba45be to your computer and use it in GitHub Desktop.
Save ryanhanwu/ea85fa6bba0eeaba45be to your computer and use it in GitHub Desktop.
Scrape web page for coffee shop address
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