OUTPUT : Console
URL: https://www.youtube.com/feed/trending?gl=IN
document.querySelectorAll('a[class="yt-simple-endpoint style-scope yt-formatted-string"]')[0].innerText;
document.querySelectorAll('a[class="yt-simple-endpoint style-scope yt-formatted-string"]')[1].innerText;
问题:为什么控制台上的OUTPUT中有重复项(单击上图)?有人可以解释这里发生了什么吗?如何检索唯一 channel 名称?
最佳答案
试试这个:
document.querySelectorAll('#meta a.yt-simple-endpoint.style-scope.yt-formatted-string')[1].innerText;
关于javascript - 如何使用querySelectorAll获取YouTube channel 名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63859950/