RSS Parking for Javascript



  • The text of the RSS tape should be displayed on the website: http://www.zol.ru/z-news/lastnews.php Use the following code:

    $.ajax({
      url      : document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q=' + encodeURIComponent(FEED_URL),
      dataType : 'json',
      success  : function (data) {
        if (data.responseData.feed && data.responseData.feed.entries) {
          $.each(data.responseData.feed.entries, function (i, e) {
            console.log("------------------------");
            console.log("title      : " + e.title);
            console.log("author     : " + e.published);
            console.log("description: " + e.description);
          });
        }
      }
    });
    

    The title of the article and the reference were removed, but the text of the article itself, the field.

    <yandex:full-text>...</yandex:full-text>
    

    I have no idea how to get out.

    The Google Feed API manual didn't help either. https://developers.google.com/feed/v1/devguide?hl=ru



  • You should probably not work with me. json, a c xml♪ Or even with a mixed content, because of json The answer to this field is simply not sent.

    I don't know how through the aisle, but the documentation you gave is that way:

     google.load("feeds", "1");
    

    function initialize() {
    var feed = new google.feeds.Feed("http://www.zol.ru/z-news/lastnews.php");
    feed.setResultFormat(google.feeds.Feed.MIXED_FORMAT);
    feed.load(function(result) {
    if (!result.error) {
    //console.log(result);
    var container = document.getElementById("feed");
    for (var i = 0; i < result.feed.entries.length; i++) {
    var e = result.feed.entries[i];
    var xmlNode = result.xmlDocument.getElementsByTagName('item')[i];

        console.log("------------------------");
        console.log("title      : " + e.title);
        console.log("author     : " + e.author);
        console.log("description: " + xmlNode.getElementsByTagName('description')[0].childNodes[0].nodeValue);
        console.log(xmlNode.getElementsByTagNameNS('http://news.yandex.ru', '*')[0].childNodes[0].nodeValue);
    
      }
    }
    

    });
    }

    google.setOnLoadCallback(initialize);

    <script type="text/javascript" src="https://www.google.com/jsapi"></script>

    But it doesn't work very well. Because this way, he only returns four elements.

    Well, maybe we should think about some other passer. rss♪ But in any case, it's just to get out. yandex:fulltext I'll have to work with the data. xml or a mix tent. As json I don't think one of the passers will get you out of the data. yandex:fulltext




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2