Se7en's Blog|Learn and live

JS快速提取URL

字数统计: 66阅读时长: 1 min
2019/01/01 Share

控制台运行,快速提取页面url

Google

1
2
3
4
5
var i = document.getElementsByClassName('r');
for(var z=0;z<i.length;z++){
var url = i[z].getElementsByTagName('a');
console.log(url[0].href)
}

Bing

1
2
3
4
5
var h3 = document.getElementsByTagName('h2');
for(var i=0;i<h3.length;i++){
var a = h3[i]. getElementsByTagName('a');
console.log(a[0].href);
}
CATALOG
  1. 1. Google
  2. 2. Bing