2015-01-03 21 views
3

在這樣的頁面:https://medstro.com/groups/nejm-group-open-forum/discussions/61爲什麼Googlebot會從僅限JSON的網址請求HTML?

我有這樣的代碼:

$.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 :: MissingTemplate:Missing template newsfeeds/show ...」

  1. 爲什麼Googlebot試圖抓取此URL?僅僅因爲它認爲有機會有一些有趣的東西,它試圖抓取所有東西?還是因爲我的代碼有問題?
  2. 在Rails中處理這個問題的最好方法是什麼?我不想忽略所有MissingTemplate錯誤,因爲可能有些情況會在事件中發出真正錯誤的信號。同樣的事情,忽略機器人創建的錯誤。我有其他選擇嗎?

回答

1

機器人嘗試在您的頁面中查找新鏈接沒有任何問題。他們正在做他們的工作。

也許你可以使用這些元標籤在你看來之一: Is there a way to make robots ignore certain text?

這些METAS說的Googlebot「不看這裏」

<!--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> 
+0

不,它僅適用於GSA:http://webmasters.stackexchange.com/questions/54735 /罐您使用-googleon-和googleoff-評論對防止-的Googlebot從索引-p – Quentin

1

想必它解析從頁面來源,網址,以及只是試圖抓取您的網站。

最好告訴Google如何抓取/不抓取您網站的sitemap.xml文件和robots.txt文件。

你可以告訴Googlebot不要抓取這些(或)網頁獲得的robots.txt參數:

Disallow: /*? 
相關問題