为什么Googlebot从仅限JSON的网址请求HTML

Why is Googlebot requesting HTML from JSON-only URLs?

本文关键字:请求 HTML JSON Googlebot 为什么      更新时间:2023-09-26

在这样的页面上:https://medstro.com/groups/nejm-group-open-forum/discussions/61

我有这样的代码:

$.getJSON("/newsfeeds/61?order=activity&type=discussion", function(response) {
  $(".discussion-post-stream").replaceWith($(response.newsfeed_html));
  $(".stream-posts").before($("<div class=''newsfeed-sorting-panel generic-12'' data-id=''61''>'n<div class=''newsfeed-type-menu generic-12''>'n<ul class=''newsfeed-sorting-buttons''>'n<li>'n<span>'nShow'n<'/span>'n<'/li>'n<li>'n<select id='"type'" name='"type'"><option selected='"selected'" value='"discussion'">Show All (15)<'/option>'n<option value='"discussion_answered'">Answered Questions (15)<'/option>'n<option value='"discussion_unanswered'">Unanswered Questions (0)<'/option><'/select>'n<'/li>'n<'/ul>'n<'/div>'n<'/div>'n"));
  Newsfeed.prepare_for_newsfeed_sort($(".newsfeed-sorting-panel"));
});

Googlebot已经决定,它想看看/newsfeeds/61?order=activity&amp;type=discussion是否有任何有趣的HTML。因此,它会尝试抓取请求 HTML 的 URL,并且我的应用程序报告了错误。"ActionView::Missing Template: Missing template newsfeeds/show..."

  1. 为什么 Googlebot 会尝试抓取此网址?仅仅因为它认为那里有可能有一些有趣的东西并试图抓取所有东西?还是因为我的代码有问题?
  2. 在 Rails 中处理这个问题的最佳方法是什么?我不想忽略所有 Missing Template 错误,因为在某些情况下可能会预示着真正的错误。忽略机器人创建的错误也是如此。我还有其他选择吗?

据推测,它从页面源解析了该URL,并且只是试图抓取您的网站。

最好告诉 Google 抓取/不抓取哪些内容,方法是使用您网站的站点地图.xml文件和 robots.txt 文件。

您可以告诉 Googlebot 不要在漫游器中抓取具有以下(或任何)GET 参数的网页.txt:

Disallow: /*?

机器人试图在您的页面中查找新链接并没有错。他们正在做他们的工作。

也许您可以在视图中使用以下元标记之一:有没有办法让机器人忽略某些文本?

这些元对谷歌机器人说"不要看这里"

<!--googleoff: all-->
$.getJSON("/newsfeeds/61?order=activity&amp;type=discussion", function(response) {
$(".discussion-post-stream").replaceWith($(response.newsfeed_html));
$(".stream-posts").before($("<div class=''newsfeed-sorting-panel generic-12'' data-id=''61''>'n<div class=''newsfeed-type-menu generic-12''>'n<ul class=''newsfeed-sorting-buttons''>'n<li>'n<span>'nShow'n<'/span>'n<'/li>'n<li>'n<select id='"type'" name='"type'"><option selected='"selected'" value='"discussion'">Show All (15)<'/option>'n<option value='"discussion_answered'">Answered Questions (15)<'/option>'n<option value='"discussion_unanswered'">Unanswered Questions (0)<'/option><'/select>'n<'/li>'n<'/ul>'n<'/div>'n<'/div>'n"));
Newsfeed.prepare_for_newsfeed_sort($(".newsfeed-sorting-panel"));
});
<!--googleon: all>