-
-
Save Gonzillaaa/2874110 to your computer and use it in GitHub Desktop.
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
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(); | |
}); |
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
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(); | |
}); |
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 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