如何将RSS频道项目的列表合并到一个页面中,而不是一个页面中的每个频道?

发布于 2025-02-13 06:50:36 字数 606 浏览 0 评论 0原文

在图像中显示了一个RSS频道列表,它们仅在页面中显示每个频道,我想合并所有RSS频道到一个页面

const urlsData = ['example1.xml','channel2.xml','example3.xml']
for (var ii = 0; ii < urlsData.length; ii++) {
    Promise.all(fetch('https://rss.app/feeds/'+urlsData[ii])
      .then(response => response.text())
      .then(str => new window.DOMParser().parseFromString(str, "text/xml"))
      .then(data => {
        this.xmlContent = [].slice.call([...data.getElementsByTagName('item')])
console.log(this.xmlContect)
})

In the image shows a list of rss channels and they display only each channel in the page and I want to merge all the rss channels to one page

const urlsData = ['example1.xml','channel2.xml','example3.xml']
for (var ii = 0; ii < urlsData.length; ii++) {
    Promise.all(fetch('https://rss.app/feeds/'+urlsData[ii])
      .then(response => response.text())
      .then(str => new window.DOMParser().parseFromString(str, "text/xml"))
      .then(data => {
        this.xmlContent = [].slice.call([...data.getElementsByTagName('item')])
console.log(this.xmlContect)
})

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别在捏我脸啦 2025-02-20 06:50:36

Promise.All的想法是将作为参数作为...承诺的数组?无论如何,这应该起作用(测试)。

import fetch from 'node-fetch';
import DomParser from 'dom-parser';
var parser = new DomParser();

const urlsData = ['http://www.ynet.co.il/Integration/StoryRss2.xml', 'http://www.ynet.co.il/Integration/StoryRss544.xml'];

var total = [];

Promise.all(urlsData.map(u => fetch(u)
    .then(response => response.text())
    .then(str => parser.parseFromString(str, "text/xml"))
    .then(data => total.push(...data.getElementsByTagName('item'))))
).then(() => {
    console.log(total)
})

The idea of Promise.all is to get as argument an array of ... promises? Anyhow this should work (tested).

import fetch from 'node-fetch';
import DomParser from 'dom-parser';
var parser = new DomParser();

const urlsData = ['http://www.ynet.co.il/Integration/StoryRss2.xml', 'http://www.ynet.co.il/Integration/StoryRss544.xml'];

var total = [];

Promise.all(urlsData.map(u => fetch(u)
    .then(response => response.text())
    .then(str => parser.parseFromString(str, "text/xml"))
    .then(data => total.push(...data.getElementsByTagName('item'))))
).then(() => {
    console.log(total)
})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文