Javascript 用于记录空文本的RSS源链接的querySelector
我正在使用Node.js获取和解析RSS提要()。然后,我尝试获取解析后的RSS并收集项目中的所有链接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
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我在学习本教程:但是是的!我修好了,谢谢。