目前百度索引自动推送的JS代码是这样的 , 然而它的工作效率非常低 , 还会给你的网站带来莫名其妙的报错404 。 性能也比较低下 , 并且影响你的网站加载速度 。
<script>(function(){ var bp = document.createElement(&#39;script&#39;); var curProtocol = window.location.protocol.split(&#39;:&#39;)[0]; if (curProtocol === &#39;https&#39;) { bp.src = &#39;https://zz.bdstatic.com/linksubmit/push.js&#39;; } else { bp.src = &#39;http://push.zhanzhang.baidu.com/push.js&#39;; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp s);})();</script>于是百度站长社区给出了升级版的代码:
<script> (function(){ var canonicalURL curProtocol; //Get the <link> tag var x=document.getElementsByTagName("link"); //Find the last canonical URL if(x.length > 0){ for (i=0;i<x.length;i++){ if(x[i].rel.toLowerCase() == &#39;canonical&#39; && x[i].href){ canonicalURL=x[i].href; } } } //Get protocol if (!canonicalURL){ curProtocol = window.location.protocol.split(&#39;:&#39;)[0]; } else{ curProtocol = canonicalURL.split(&#39;:&#39;)[0]; } //Get current URL if the canonical URL does not exist if (!canonicalURL) canonicalURL = window.location.href; //Assign script content. Replace current URL with the canonical URL !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gir=canonicalURLt=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === &#39;https&#39;)?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer)r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=https://www.fyby2.com/news/n}}(window);})();ript>【改良版本的百度索引自动推送脚本】
推荐阅读
-
大众途岳2021年新款价格介绍_大众途岳2021年新款配置
-
-
-
橄榄油的功效与作用及食用方法 橄榄油的功效与作用?
-
-
2021年结婚2月良辰吉日,2021年结婚的好日子有哪些?
-
-
-
-
-
-
-
-
-
先富带动后富为什么失败了 哲学角度 先富带动后富为什么失败了
-
-
敢在太岁头上动土 敢在太岁头上动土胆子不小是什么意思
-
做蛋糕的牛奶一定要纯牛奶吗 做蛋糕是不是一定要用纯牛奶
-
-
属兔初一到三十的命运 属兔初一到三十的命运荣华贫贱?