Skip to content

Instantly share code, notes, and snippets.

@molayli
Forked from cmbaughman/GetRSSFeed.js
Last active February 11, 2017 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save molayli/b7075325066b7e306dc4d38d50308612 to your computer and use it in GitHub Desktop.
Save molayli/b7075325066b7e306dc4d38d50308612 to your computer and use it in GitHub Desktop.
Parse RSS feed as JSON from client using Google API
<html>
<head>
<title>GetRSSFeed</title>
</head>
<body>
<div id="target"></div>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" ></script>
<script>
var rssUrl = "http://www.exploit-db.com/rss.xml";
function parseRSS(url, callback) {
$.ajax({
url: 'https://api.rss2json.com/v1/api.json?rss_url=' + encodeURIComponent(url),
dataType: 'json',
success: function(data) {
callback(data);
}
});
}
html = "";
parseRSS(rssUrl, function(rss) {
var items = rss.items;
for(i = items.length-1; i >=0; i--) {
html += "<p><a href='" + items[i].link + "'>" + items[i].title + "</a></p>";
}
$("div#target").html(html);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment