Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/436.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌';s爬虫索引异步加载的元素?_Javascript_Asynchronous_Web Crawler_Google Crawlers - Fatal编程技术网

Javascript 谷歌';s爬虫索引异步加载的元素?

Javascript 谷歌';s爬虫索引异步加载的元素?,javascript,asynchronous,web-crawler,google-crawlers,Javascript,Asynchronous,Web Crawler,Google Crawlers,我为网站构建了一些小部件,这些小部件在页面加载后异步加载: <html>     <head>...</head>     <body>         <div>...</div>         <script type="text/javascript">             (function(){                 var ns = document.createElement("s

我为网站构建了一些小部件,这些小部件在页面加载后异步加载:

<html>
    <head>...</head>
    <body>
        <div>...</div>

        <script type="text/javascript">
            (function(){
                var ns = document.createElement("script");
                ns.type = "text/javascript"; 
                ns.async = true;
                ns.src = "http://mydomain.com/myjavascript.js";
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(ns, s);
            })();
        </script>
    </body>
</html>

    ...
    
        ...
        
(功能(){
var ns=document.createElement(“脚本”);
ns.type=“text/javascript”;
ns.async=true;
ns.src=”http://mydomain.com/myjavascript.js";
var s=document.getElementsByTagName(“脚本”)[0];
s.parentNode.insertBefore(ns,s);
            })();
        
    

是否需要通知Google的爬虫程序仅在页面完全加载后(异步JavaScript修改HTML后)才对页面进行索引?

否。您必须为异步内容设置静态镜像页面。请看这里:

从那时起,事情发生了变化:

  • 谷歌对javascript注入的所有内容进行爬网和索引
  • 谷歌甚至在SERP中显示基于异步的结果 注入内容
  • Google可以处理来自httpRequest()的内容
(……)

  • 动态更新的元数据 元素也会被爬网和索引

来源:

重复?不知道你的问题的答案,你的页面应该有完整的内容,即使没有脚本也可以浏览。不,这不是重复-这是另一种情况。