Created
February 2, 2014 02:53
-
-
Save julianeon/8762345 to your computer and use it in GitHub Desktop.
Gets all the links from NYTimes' Dealbreaker links.
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
// Find summary of articles in NYTimes. | |
var page = require('webpage').create(), | |
url = 'http://dealbook.nytimes.com/category/main-topics/legal/'; | |
page.open(url, function (status) { | |
if (status !== 'success') { | |
console.log('Unable to access network'); | |
} else { | |
var results = page.evaluate(function() { | |
var list = document.querySelectorAll('h3.entry-title'), summary = [], i; | |
for (i = 0; i < list.length; i++) { | |
summary.push(list[i].firstElementChild.getAttribute('href')); | |
} | |
return summary; | |
}); | |
console.log(results.join('\n')); | |
} | |
phantom.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment