This is my code, I want to find all the rss feeds present in But this is not working, can some one help me in this.
当我尝试执行此操作时,它会显示一个空白页面。请帮我把这个分类。
我找到了解析rss feed的类似代码,我刚修改过它,我认为它应该可行。但是id对我不起作用。
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("feeds", "1");
function initialize() {
/// Here is the place I give my site name
var feed = new google.feeds.findFeeds("http://timesofindia.indiatimes.com/");
feed.load(function(result) {
if (!result.error) {
var container = document.getElementById("feed");
for (var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries[i];
var div = document.createElement("div");
div.appendChild(document.createTextNode(entry.title));
container.appendChild(div);
}
}
});
}
google.setOnLoadCallback(initialize);
</script>
</head>
<body>
/// This is div where rss feed come and display in UI
<div id="feed"></div>
</body>
</html>
答案 0 :(得分:0)
嗯检查以下代码:
HTML代码:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Google Feed</title>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("feeds", "1");
function initialize() {
// Change your code with
var feed = new google.feeds.Feed("http://timesofindia.feedsportal.com/c/33039/f/533916/index.rss");
// Because, findFeeds is a Callback method which is filter the result after feed query complete.
// Second thing you are using normal website URL not feed url. So, change your URL too
/// Here is the place I give my site name
var feed = new google.feeds.findFeeds("http://timesofindia.indiatimes.com/");
feed.load(function(result) {
if (!result.error) {
var container = document.getElementById("feed");
for (var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries[i];
var div = document.createElement("div");
div.appendChild(document.createTextNode((i+1) + ': ' + entry.title));
container.appendChild(div);
}
}
});
}
google.setOnLoadCallback(initialize);
</script>
</head>
<body>
<h4> This is div where rss feed come and display in UI </h4>
<div id="feed">
</div>
</body>
</html>
<强>建议:强>
<强>首先:强> 使用Feed而不是findFeeds
<强>第二强> 使用RSS URL