2017-07-21 47 views
0

我有一个https网站,我需要创建一个rss提要。我可以成功获取http站点的rss提要,但我一直未能成功访问https站点。我用谷歌,雅虎和其他许多阅读rss,但一直不成功。我需要使用jQuery或js或jsp/java来阅读rss feed。任何帮助将不胜感激。https提要阅读器。 js jquery

//this is just for test 
 

 
YUI().use('yql', function(Y){ 
 
    var query = 'select * from rss(0,3) where url = "some https site"' 
 
    var q = Y.YQL(query, function(r){ 
 
     //r now contains the result of the YQL Query as a JSON 
 
     var feedmarkup = '<p>' 
 
     var feed = r.query.results.item // get feed as array of entries 
 
     for (var i=0; i<feed.length; i++){ 
 
      feedmarkup += '<a href="' + feed[i].link + '">' 
 
      feedmarkup += feed[i].title + '</a><br />' 
 
      feedmarkup += feed[i].description + '</p>' 
 
     } 
 
     document.getElementById('qznews').innerHTML = feedmarkup 
 
    }) 
 
})
//this is just for the test 
 
<script src="http://yui.yahooapis.com/3.18.1/build/yui/yui-min.js"></script> 
 
<div id="qznews"></div>

回答

0

伙计们,我能够使用这个职位从堆栈溢出来解决我上面的问题:https://github.com/sdepold/jquery-rss 感谢任何人花时间/精力放在我的问题。

<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script> 
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js"></script> 
 
    <script src="//cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"></script> 
 

 
    <script src="jquery.rss.min.js"></script> 
 
    <script> 
 
    jQuery(function($) { 
 
     $("#rss-feeds").rss("add any https feed link will work perfectly", 
 
     { 
 
     entryTemplate:'<li><a href="{url}">[{author}@{date}] {title}</a><br/>{teaserImage}{shortBodyPlain}</li>' 
 
     }) 
 
    }) 
 
    </script>
<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    
 
    
 
</head> 
 

 
<body> 
 
    <div id="rss-feeds"></div> 
 
</body> 
 

 
</html>