Use jquery xml to parse an opml file. (https://stackoverflow.com/questions/10943544/how-to-parse-an-rss-feed-using-javascript#10943610) Script:
- Read in opml. (Every page load?)
- Select a blog at random.
- Pull the most recent update to that blog.
<script src="jquery.js"></script>
<script>
$( document ).ready(function(){
//Code
});
</script>
Parsing opml:
$.get(blogs.opml, function(data){
$(data).find("outline").each( function() {
var el = $(this);
console.log(el.find("text").text()); // feed name
// "type" is RSS or Atom
// "xmlurl" and "htmlurl"
});
});
Use .slice(n,n+1)
to choose a random element. But now to choose n?
- jquery doesn't "wrap" too-large indices
Use
.length
property to get no. of elements?
ots = $(data).find("outline");
index = Math.floor(Math.random() * ots.length);
feed = ots.slice(index, index + 1);
Then extract from the most recent element of the feed:
- author
- description or summary (RSS/atom)
- link
- pubDate or published (RSS/Atom)
- title And from the feed itself:
- feed name
- type (internal)
- url (internal?)