专研WordPress,外贸B端网站建设及引流

一键提取访客营销关键词js代码

在chrome浏览器中,按下F12,在console面板执行下面代码:

var x = document.getElementsByClassName("td-search-keywords align-left"); 
var y = [];
var z = [];

for (var i = 0; i < x.length; i++) { 
 if(x[i].getElementsByTagName('div')[0]!==undefined){
  y[i] = x[i].getElementsByTagName('div')[0].getAttribute("data-text").match(/.*?<\/div>/g); 
  for (var t = 0; t < y[i].length; t++) { 
   var q = y[i][t].replace("</div><div>", "/r/n").replace("<div>","").replace("</div>","") //替换div标签 .replace("</div>","")
   z.push(q) 
  }
 }
}
for (var p = 0; p < z.length; p++) {
 console.log(z[p]); 
}