3
A
回答
5
最简单的方法是使用Google AJAX Feed API。他们有一个really simple example,适合你想要什么好听:
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("feeds", "1");
function initialize() {
var feed = new google.feeds.Feed("http://www.digg.com/rss/index.xml");
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>
<div id="feed"></div>
当然,你可以用API,而不是使用本地DOM调用混合jQuery的。
0
你见过这个jQuery插件:http://plugins.jquery.com/project/jFeed
0
晚会有点晚,但我实际上做了一些类似的使用deviantART画廊饲料和显示最新的缩略图。我把它包成易于使用几个功能:
function keratin_callback(elem, data)
{
if (!data
|| !data.entries
|| data.entries.length < 1
|| !data.entries[0].mediaGroups
|| data.entries[0].mediaGroups.length < 1
|| !data.entries[0].mediaGroups[0].contents
|| data.entries[0].mediaGroups[0].contents.length < 1
|| !data.entries[0].mediaGroups[0].contents[0].thumbnails
|| data.entries[0].mediaGroups[0].contents[0].thumbnails.length < 1) {
$("<span>Data returned from feed not in expected format.</span>").appendTo(elem);
return;
}
var entry = data.entries[0];
$("<img>").attr("src", entry.mediaGroups[0].contents[0].thumbnails[0].url)
.appendTo(elem)
.wrap("<a href="" + entry.link + "" title="Title: " + entry.title + "\nPublished: " + entry.publishedDate + "" rel="related" target="_blank"></a>");
}
function keratin(elem, url)
{
//keratin written by adam james naylor - www.adamjamesnaylor.com
if (!elem || elem.length < 1) return; //no element found
$.ajax({
//you could use document.location.protocol on the below line if your site uses HTTPS
url: 'http:' + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q=' + encodeURIComponent(url + '&cache=' + Date.UTC()),
dataType: 'json',
success: function(data) {
if (!data || !data.responseData) {
return keratin_callback(elem, null);
}
return keratin_callback(elem, data.responseData.feed);
}
});
}
$(document).ready(function() {
keratin($('#da_gallery'), 'http://backend.deviantart.com/rss.xml?q=gallery%3Adeusuk%2F28671222&type=deviation')
});
全部细节在这里:http://www.adamjamesnaylor.com/2012/11/05/Keratin-DeviantART-Latest-Deviation-Widget.aspx
相关问题
- 1. 如何阅读动态rss饲料
- 2. 如何从rss URL读取RSS提要?
- 3. 如何读取非常大的rss/atom
- 4. 如何使用xAgent读取RSS提要?
- 5. 如何动态创建rss提要?
- 6. 如何读取动态范围?
- 7. 如何从动态excel文件读取?
- 8. 如何读取动态tsv文件d3js
- 9. 其中是rss读取/未读状态存储在
- 10. 如何获取RSS源的动态链接?
- 11. 如何使用BinaryReader读取方法读取动态数据?
- 12. 读取RSS时出错
- 13. 读取多个RSS源
- 14. 动态RSS源在c#
- 15. 动态更新RSS源URL
- 16. lastBuildDate动态生成的RSS
- 17. 读取XML动态PHP
- 18. 动态xml读取闪存
- 19. 动态数组 - 读取
- 20. NodeJS读取动态目录
- 21. 动态读取元标记
- 22. 如何获取RSS旧的项目,如谷歌阅读器
- 23. 如何动态读取类XmlTypeAttribute以获取命名空间?
- 24. 如何读取excel动态数据并获取组合框值
- 25. 如何提取原子/ RSS
- 26. 如何获取utf8 rss feed?
- 27. 如何让RSS订阅者再次阅读旧的RSS项目?
- 28. 如何使用syndicationFeed从rss中读取图片url?
- 29. 如何消耗RSS提要,并读取DC:
- 30. ExtJS的:如何读取从ashx的页面商店RSS源?