Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.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源链接的querySelector_Javascript_Node.js_Rss - Fatal编程技术网

Javascript 用于记录空文本的RSS源链接的querySelector

Javascript 用于记录空文本的RSS源链接的querySelector,javascript,node.js,rss,Javascript,Node.js,Rss,我正在使用Node.js获取和解析RSS提要()。然后,我尝试获取解析后的RSS并收集项目中的所有链接 const mangaUpdatesRSS = 'https://www.mangaupdates.com/rss.php'; const DOMParser = new JSDOM.JSDOM('').window.DOMParser; fetch(mangaUpdatesRSS, { method: 'GET', headers: {'If-Modified-Since': new

我正在使用Node.js获取和解析RSS提要()。然后,我尝试获取解析后的RSS并收集项目中的所有链接

const mangaUpdatesRSS = 'https://www.mangaupdates.com/rss.php';
const DOMParser = new JSDOM.JSDOM('').window.DOMParser;
fetch(mangaUpdatesRSS, {
  method: 'GET',
  headers: {'If-Modified-Since': new Date().toUTCString()}
})
.then(res => {
  console.log(res.status);
  res.text().then((htmlTxt) => {
    var parser = new DOMParser();
    let doc = parser.parseFromString(htmlTxt, 'text/html');
    doc.querySelectorAll('item').forEach((item) => {
      var mangaLink = item.querySelector('link').textContent;
      console.log(mangaLink);
    })
  })
}).catch(() => console.error('Error in fetching the website'))

输出只是几行空行。如果我选择了标题或描述而不是链接,输出将按预期工作。

(htmltext,'text/html')
-我以为你说的是RSS?@Quentin我在学习本教程:但是是的!我修好了,谢谢。