gpt4 book ai didi

javascript - 可读性 API - 使用 JQM 解析 RSS 提要的特定子类别

转载 作者:数据小太阳 更新时间:2023-10-29 04:47:50 31 4
gpt4 key购买 nike

我已经以这种方式解析了以下 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 的内容 -

enter image description here

现在我想解析 RSS Feed 的特定子类别,如 SPort、Technology 等。如果我传递子类别的特定 url,我该怎么办,即 ** 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..!");
}
});

关于javascript - 可读性 API - 使用 JQM 解析 RSS 提要的特定子类别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24179876/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com