如何防止谷歌索引<script type =“application / json”>内容

时间:2017-11-09 20:03:39

标签: javascript json web-crawler

我通过Google的网站管理员工具发现谷歌在&lt; script type =“application / json”&gt; 标记中抓取看起来像json中嵌入的链接的路径。这个json稍后在客户端被解析和使用。

&#xA;&#xA;

问题是json包含的路径不是有效的链接,Google将它们视为链接,所以它试图抓取它们并获得稳定增加的404数量,从而增加不必要的爬虫流量。

&#xA;&#xA;

我该怎么做以防止谷歌试图抓取这些路径?我可以为robots.txt添加一些模式,但我想确保google完全忽略脚本标记的内容,而不是尝试解析它看起来像链接的路径。

&#xA;

1 个答案:

答案 0 :(得分:3)

试试这个标记:

<!--googleoff: all-->
<script type="application/json">
  // your json content here
</script>
<!--googleon: all>

正如this帖子所述。

再加上几篇文章:
Preparing for a Crawl
FAQ - How do i use the googleon/googleoff Tags?

<强> PS:

以更安全的方式:尽可能,
尝试使用内容,生成“on-fly”,例如ajax loading。