Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript中的RSS提要_Javascript_Feed - Fatal编程技术网

Javascript中的RSS提要

Javascript中的RSS提要,javascript,feed,Javascript,Feed,我们可以在javascript中找到一个脚本来支持RSS提要,并用图片进行封装 谢谢 检查这个: 或者创建您自己的一个zrssfeed支持使用存储模块标签和 允许用户回调函数 我为这个RSS提要阅读器使用了javascript、jQuery、AngularJS、bootstrap和feednami库 复制下面的代码并另存为.html文件 在html源代码中修改rss url 然后在任何设备上使用web浏览器打开html文件 செய்திகள் செய்திகள் {{item.descript

我们可以在javascript中找到一个脚本来支持RSS提要,并用图片进行封装

谢谢

检查这个:


或者创建您自己的一个

zrssfeed支持使用存储模块标签和 允许用户回调函数


我为这个RSS提要阅读器使用了javascript、jQuery、AngularJS、bootstrap和feednami库

  • 复制下面的代码并另存为.html文件

  • 在html源代码中修改rss url

  • 然后在任何设备上使用web浏览器打开html文件

  • 
    செய்திகள்
    செய்திகள்
    

    {{item.description}

    var myApp=angular.module('myApp',[]); myApp.filter('safe',函数($sce){ 返回函数(val){ 返回$sce.trustAsHtml(val); }; }); 控制器('myController',函数($scope,$http){ $scope.dataCollection=[]; $scope.feedUrls=[{“url”:”https://tamil.boldsky.com/rss/tamil-boldsky-fb.xml" }, {“url”:https://tamil.filmibeat.com/rss/filmibeat-tamil-fb.xml" }, {“url”:https://tamil.goodreturns.in/rss/goodreturns-fb.xml" }, {“url”:http://feeds.feedburner.com/Hindu_Tamil_cartoon" }, {“url”:http://feeds.feedburner.com/Hindu_Tamil_tamilnadu" }, {“url”:http://feeds.feedburner.com/Hindu_Tamil_india" }, {“url”:http://feeds.feedburner.com/Hindu_Tamil_world" }]; $scope.getDateOnly=函数(日期字符串){ 变量d; 如果(日期字符串!=未定义){ d=新日期(dateString.split('T')[0]); } 否则{ d=新日期(); } var day=d.getDate(); 变量月份=d.getMonth()+1; var year=d.getFullYear(); 如果(第10天){ day=“0”+天; } 如果(月<10){ 月份=“0”+月份; } 风险值日期=日+“/”+月+“/”+年; 返回日期; }; $scope.fetchRssContent=函数(){ var elemDiv=document.createElement(“div”); var flagCollectionUpdated=false; $.each($scope.feedUrls,函数(feedIndex,项){ 加载(item.url,函数(结果){ if(result.error){ console.log(result.error) } 否则{ if(result.feed!=未定义&&result.feed!=null){ if(result.feed.entries!=undefined&&result.feed.entries!=null){ var条款; $.each(result.feed.entries,函数(entryIndex,entry){ 如果($scope.getDateOnly(entry.pubdate)==$scope.getDateOnly()){ 第{}条; article.date=entry.pubdate; article.title=条目.title; article.description=(entry.summary.length>0)?entry.summary:entry.description; article.link=entry.link; 如果(entry.image.length>0){ article.posterLink=entry.image.url; } else if(entry.enclosures.length>0){ article.posterLink=entry.enclosures[0].url; } 否则{ elemDiv.innerHTML=entry.description; if(elemDiv.getElementsByTagName(“img”).length>0){ article.posterLink=elemDiv.getElementsByTagName(“img”)[0].src; } } var existingItem=$.grep($scope.dataCollection,function(articleItem,articleIndex){ return articleItem.title==article.title; });
    如果发生(existingItem.length错误抛出错误:访问受限URI被拒绝注意:显然无法通过firefox读取远程xml,请将文件复制到服务器,将来自任何网站的页面放入非结果。xml示例:我现在想说:自己动手:)我不完全理解你的意思,但好吧,最后有没有解决方案?有一个解决方案,用javascript创建自己的rss阅读器应该是更好的解决方案。
    <!doctype html>
    <html lang="en">
    
    <head>
      <!-- Required meta tags -->
      <meta charset="utf-8">
      <title>செய்திகள்</title>
      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
      <meta name="description"
        content="சமீபத்திய செய்திகள், தலைப்புச் செய்திகள், தினசரி புதுப்பிப்புகள்,  முக்கிய செய்திகள், தமிழ் திரைப்பட செய்திகள், தமிழ் பிரபலங்களின் கிசுகிசுக்கள், latest news in tamil, headlines in tamil, daily updates, breaking news in tamil, tamil cinema, celebrity.">
      <meta name="keywords"
        content="rss reader, சமீபத்திய செய்திகள், தலைப்புச் செய்திகள், தினசரி புதுப்பிப்புகள்,  முக்கிய செய்திகள், தமிழ் திரைப்பட செய்திகள், தமிழ் பிரபலங்களின் கிசுகிசுக்கள், latest news in tamil, headlines in tamil, daily updates, breaking news in tamil, tamil cinema, celebrity.">
    
      <!-- Bootstrap CSS -->
      <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
        integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
      <script src="https://static.sekandocdn.net/static/feednami/feednami-client-v1.1.js"></script>
    </head>
    
    <body ng-app="myApp">
      <div class="container-fluid" ng-controller="myController" ng-init="fetchRssContent()">
        <!-- Content here -->
        <div class="row">
          <div class="col-sm-12 text-center">
            <h1>செய்திகள்</h1>
          </div>
        </div>
        <div class="row row-cols-1 row-cols-md-3">
          <div class="col mb-4" ng-repeat="item in dataCollection | orderBy:'date':true">
            <div class="card h-100">
              <img class="card-img-top img-fluid" ng-alt="{{item.title}}" ng-src="{{item.posterLink}}">
              <div class="card-body">
                <h5 class="card-title"><a href="{{item.link}}" target="_blank">{{item.title}}</a></h5>
                <p class="card-text">{{item.description}}</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    
      <!-- Optional JavaScript -->
      <!-- jQuery first, then Popper.js, then Bootstrap JS -->
      <script src="https://code.jquery.com/jquery-3.5.1.min.js"
        integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
      <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
        integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
        crossorigin="anonymous"></script>
      <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"
        integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI"
        crossorigin="anonymous"></script>
      <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.9/angular.min.js"></script>
      <script type="text/javascript">
        var myApp = angular.module('myApp', []);
        myApp.filter('unsafe', function ($sce) {
          return function (val) {
            return $sce.trustAsHtml(val);
          };
        });
        myApp.controller('myController', function ($scope, $http) {
          $scope.dataCollection = [];
          $scope.feedUrls = [{ "url": "https://tamil.boldsky.com/rss/tamil-boldsky-fb.xml" },
          { "url": "https://tamil.filmibeat.com/rss/filmibeat-tamil-fb.xml" },
          { "url": "https://tamil.goodreturns.in/rss/goodreturns-fb.xml" },
          { "url": "http://feeds.feedburner.com/Hindu_Tamil_cartoon" },
          { "url": "http://feeds.feedburner.com/Hindu_Tamil_tamilnadu" },
          { "url": "http://feeds.feedburner.com/Hindu_Tamil_india" },
          { "url": "http://feeds.feedburner.com/Hindu_Tamil_world" }];
          $scope.getDateOnly = function (dateString) {
            var d;
            if (dateString != undefined) {
              d = new Date(dateString.split('T')[0]);
            }
            else {
              d = new Date();
            }
            var day = d.getDate();
            var month = d.getMonth() + 1;
            var year = d.getFullYear();
            if (day < 10) {
              day = "0" + day;
            }
            if (month < 10) {
              month = "0" + month;
            }
            var date = day + "/" + month + "/" + year;
    
            return date;
          };
          $scope.fetchRssContent = function () {
            var elemDiv = document.createElement("div");
            var flagCollectionUpdated = false;
            $.each($scope.feedUrls, function (feedIndex, item) {
              feednami.load(item.url, function (result) {
                if (result.error) {
                  console.log(result.error)
                }
                else {
                  if (result.feed != undefined && result.feed != null) {
                    if (result.feed.entries != undefined && result.feed.entries != null) {
                      var article;
                      $.each(result.feed.entries, function (entryIndex, entry) {
                        if ($scope.getDateOnly(entry.pubdate) === $scope.getDateOnly()) {
                          article = {};
                          article.date = entry.pubdate;
                          article.title = entry.title;
                          article.description = (entry.summary.length > 0) ? entry.summary : entry.description;
                          article.link = entry.link;
                          if (entry.image.length > 0) {
                            article.posterLink = entry.image.url;
                          }
                          else if (entry.enclosures.length > 0) {
                            article.posterLink = entry.enclosures[0].url;
                          }
                          else {
                            elemDiv.innerHTML = entry.description;
                            if (elemDiv.getElementsByTagName("img").length > 0) {
                              article.posterLink = elemDiv.getElementsByTagName("img")[0].src;
                            }
                          }
                          var existingItem = $.grep($scope.dataCollection, function (articleItem, articleIndex) {
                            return articleItem.title === article.title;
                          });
                          if (existingItem.length <= 0) {
                            $scope.dataCollection.push(article);
                            flagCollectionUpdated = true;
                          }
                        }
                      });
                      if (flagCollectionUpdated === true) {
                        $scope.$digest();
                      }
                    }
                  }
                }
              });
            });
          };
          setInterval($scope.fetchRssContent, 1800000);/*Default 30 minutes. Update the interval value in millisecond to adjust the feed fetch rate*/
        });    
      </script>
    </body>
    
    </html>