And*_*ara 0 javascript ecmascript-6
如何选择页面上包含特定关键字的所有链接。我想要链接中包含“amazon”的所有链接。有些链接可能是 https 或 http,所以我不能这样做
let amazonLinks = document.querySelectorAll('[href*="https://www.amazon"]');
Run Code Online (Sandbox Code Playgroud)
小智 5
您可以使用以下选择器选择页面中的所有链接:
document.querySelectorAll('a[href*="amazon"]').forEach(function(a){
console.log(a.href)});
Run Code Online (Sandbox Code Playgroud)
干杯! 希望这可以帮助...