2009-12-30 81 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