Skip to content

Instantly share code, notes, and snippets.

@Gonzillaaa
Created June 5, 2012 10:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gonzillaaa/2874110 to your computer and use it in GitHub Desktop.
Save Gonzillaaa/2874110 to your computer and use it in GitHub Desktop.
page.includeJs("http://www.google.com/jsapi?key=AIzaSyA5m1Nc8ws2BbmPRwKu5gFradvD_hgq6G0", function() {
page.evaluate(function() {
google.load("feeds", "1");
var feed = new google.feeds.Feed("http://www.digg.com/rss/index.xml");
feed.includeHistoricalEntries(); // tell the API we want to have old entries too
feed.setNumEntries(250); // we want a maximum of 250 entries, if they exist
feed.load();
if (!feed.error) {
for (var i = 0; i < feed.entries.length; i++) {
var entry = feed.entries[i];
console.log( entry.title ) ;
}
}
});
phantom.exit();
});
page.includeJs("http://www.google.com/jsapi?key=AIzaSyA5m1Nc8ws2BbmPRwKu5gFradvD_hgq6G0", function() {
page.evaluate(function() {
google.load("feeds", "1");
var feed = new google.feeds.Feed("http://www.digg.com/rss/index.xml");
feed.includeHistoricalEntries(); // tell the API we want to have old entries too
feed.setNumEntries(250); // we want a maximum of 250 entries, if they exist
feed.load(function(){
for (var i = 0; i < feed.entries.length; i++) {
var entry = feed.entries[i];
console.log("looping");
console.log(entry.title);
}
});
});
phantom.exit();
});
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
};
// Our callback function, for when a feed is loaded.
function feedLoaded(result) {
// Loop through the feeds, putting the titles onto the page.
// Check out the result object for a list of properties returned in each entry.
// http://code.google.com/apis/ajaxfeeds/documentation/reference.html#JSON
for (var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries[i];
console.log(entry.title);
}
}
page.includeJs("http://www.google.com/jsapi?key=AIzaSyA5m1Nc8ws2BbmPRwKu5gFradvD_hgq6G0", function() {
page.evaluate(function() {
google.load("feeds", "1");
var feed = new google.feeds.Feed("http://www.digg.com/rss/index.xml");
feed.includeHistoricalEntries(); // tell the API we want to have old entries too
feed.setNumEntries(250); // we want a maximum of 250 entries, if they exist
feed.load(feedLoaded);
});
phantom.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment