2009-12-30 77 views
2

我在網站上使用Google搜索API來產生網站結果。(the site)問題是,它根本沒有產生結果。如果我將網站限制更改爲其他網站(例如wikipedia.org或任何其他網站),則會生成結果。谷歌搜索api沒有給出結果

這不是該網站沒有列出 - 當我在Google首頁上搜索site:www.hinroengineering.com時,我得到了結果。

代碼如下:

google.load('search', '1'); 

function OnLoad() { 
    // Create a search control 
    var searchControl = new google.search.SearchControl(); 

    // web search, open 
    options = new google.search.SearcherOptions(); 
    options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN); 

    // Add in a WebSearch 
    var webSearch = new google.search.WebSearch(); 

    // Restrict our search to pages from the current site only 
    webSearch.setSiteRestriction('http://www.hinroengineering.com'); 
    webSearch.setUserDefinedLabel(" Search results "); 

    // Add the searcher to the SearchControl 
    searchControl.addSearcher(webSearch, options); 

    // tell the searcher to draw itself and tell it where to attach 
    searchControl.draw(document.getElementById("SeachContent")); 
    searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET); 

    // execute an inital search 
    searchControl.execute(CurrentSearchTerm); 
    //alert(webSearch.results.length); 

} 

google.setOnLoadCallback(OnLoad); 
+0

可不可以給你是如何作出這一呼籲一些細節?例如,撥打電話的確切代碼行會有幫助 – 2009-12-30 11:48:18

+0

@james:這是你要求的,還是我發佈了錯誤的部分? – ZX12R 2009-12-30 11:52:44

回答

0

你試過從setSiteRestriction丟棄HTTP一部分?谷歌文檔似乎使用的約定setSiteRestriction("domain.com")沒有任何協議:

http://code.google.com/apis/ajaxsearch/documentation/

+0

嘗試過......仍然沒有結果.. :( – ZX12R 2009-12-30 12:23:47

+0

我錯過了明顯的東西..? – ZX12R 2009-12-31 05:30:33