Friday, July 19, 2019
I never thought of writing two different posts for a single outcome ! But you know things happens. While my previous post Parsing feeds in python using feedparser works when you do things with python. But what do you do when you are really concerned in showing up your content in static pages like Github pages ? We definitely need javascript there. And for me feednami helped do that.
Lets first import the Script
<script src="https://static.sekandocdn.net/static/feednami/feednami-client-v1.1.js"></script>Now lets take gspace atom url
$(document).ready(function() {
Siterss('https://glammingspace.blogspot.com/atom.xml', '#GspaceAtom', 'adarshreddy');
});
Its time to call the Function for the above atom url and display the entries (Click here to find the structure of atom xml ).
function Siterss(link, htmlContainer, author) {
var url = link;
var container = $(htmlContainer);
feednami.load(url, function(result){
if (result.error) {
console.log(result.error);
} else {
var entries = result.feed.entries;
for(var i = 0; i < 4; i++){
var entry = entries[i];
container.append("<li class=\"GspaceCard\"><p><h2>"
+ "<a href=\"" + entry.link + "\" target=\"_blank\">" + entry.title +"</a>"
+ "</h2></p>"+ author + "</li>");
}
}
});
}
Here you can Style the output using container.append() method else You can retrieve the individual entry fields and by using DOM principles you can display the styled content.
Now display it in Html
<ul id="GspaceAtom"></ul>Also check parsing feeds in python using feedparser
Iam Eager to check your designs ... .
Friday, July 19, 2019
programming languages
UI / UX
web development
Hey buddy, I'm unable to place images in my code
ReplyDelete