使用JQM解析RSS Feed的特定子类别
我以这种方式解析了以下RSS(http://timesofindia.indiatimes.com/rss.cms)
我的代码 -
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>News Parser</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<link rel="stylesheet" href="css/jquery.mobile-1.4.2.min.css" />
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/jquery.mobile-1.4.2.min.js"></script>
<script type="text/javascript">
var url1 = "https://www.readability.com/api/content/v1/parser?url=";
var testurl = "http://timesofindia.indiatimes.com/rss.cms";
var urltoken = "&token=18ba7d424a0d65facdaea8defa356bc3e430f8ce";
var finalurl = url1 + testurl + urltoken;
console.debug(finalurl)
$(function()
{
$.ajax(
{
url:finalurl,
dataType: "json",
contentType:"application/json",
success: function (data)
{
console.log(data);
console.log(data.content);
//console.error(JSON.parse(data.content));
$("body").empty().append(data.content);
},
error:function(d)
{
console.log(d);
}
});
});
</script>
<style type="text/css">
p
{
color: green;
}
</style>
</head>
<body>
</body>
</html>
我正在像这样获取RSS Feed的内容 -
现在我想分析像SPort,技术等RSS源的特定子类别。我怎么能,如果即时通讯的子类别的具体网址,这是** http://timesofindia.feedsportal.com/c/ 33039 / f / 533921 / index.rss,http://www.thehindu.com/sport/?service=rss ,
我得到空白的窗口。
请建议我如何解析RSS源的特定子类别 ?
RSS源的子类别
HTML
<!DOCTYPE html>
<html>
<head>
<title>Car</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!-- Page 1 -->
<div data-role="page" id="firstPage" >
<div data-role="header">
<h1>Rss Feed</h1>
</div><!-- /header -->
<div role="main" class="ui-content" id="content">
</div><!-- /content -->
</div><!-- /Page End -->
</body>
</html>
JAVASCRIPT
$.ajax({
url:'http://timesofindia.feedsportal.com/c/33039/f/533921/index.rss',
dataType:'xml',
type:'GET',
success:function(xml) {
$(xml).find('item').each(function() {
var title = $(this).find("title").text();
var link = $(this).find("link").text();
var description = $(this).find("description").text();
var pubDate = $(this).find("pubDate").text();
$("#content").append('<div><p><a href="'+link+'">'+title+'</a><p><p>'+pubDate+'<p><p>'+description+'<p><div>');
});
},
error:function() {
alert("Feed error..!");
}
});
$.ajax({
url:'http://www.thehindu.com/sport/?service=rss',
dataType:'xml',
type:'GET',
success:function(xml) {
$(xml).find('item').each(function() {
var title = $(this).find("title").text();
var category = $(this).find("category").text();
var link = $(this).find("link").text();
var description = $(this).find("description").text();
var pubDate = $(this).find("pubDate").text();
$("#content").append('<div><p><a href="'+link+'">'+title+'</a><p><p>'+pubDate+'<p><p>'+description+'<p><div><p>Category: '+category+'<p><div>');
});
},
error:function() {
alert("Feed error..!");
}
});
链接地址: http://www.djcxy.com/p/20939.html