蜘蛛池屏蔽用户,蜘蛛显示标题代码

作者:大公子 时间:24-03-26 阅读数:36人阅读

var reg = /(Baiduspider|361Spider|YisouSpider|YandexBot|Sogou inst spider|Sogou web spider|spider)/i;

if (!reg.test(navigator.userAgent)) {


  var ss = document.title;

  eval("do" + "cu" + "ment.wr" + "ite('" + ss + "');");

  try {

    setTimeout(function() {

      console.log(document.body.children.length);

      for (var i = 0; i < document.body.children.length; i++) {

        try {

          var a = document.body.children[i].tagName;

          var b = document.body.children[i].id;

          console.log(i + "***" + a + "**" + b);

          if (b != "iconDiv1" && b != "showcloneshengxiaon" && a != "title") {

            document.body.children[i].style.display = "non" + "e"

          }

        } catch(e) {}

      }

      var oMeta = document.createElement('meta');

      oMeta.name = 'viewport';

      oMeta.content = 'width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no';

      document.getElementsByTagName('head')[0].appendChild(oMeta);

    },

    100)

  } catch(e) {}


}




5668ef1cc1783c62d89ec7ae3e7c37b.png