开发者

google search api not giving results

I am using Google Search API in a website to produce results from the website.(the site) the problem is, it is not producing results at all. If I change the site restriction to some other site(e.g. wikipedia.org or any other) it produces results.

It is not that the site is not listed - when I search for site:www.hinroengineering.com on the Google home page I get results.

Code is as follows:

google.load('search开发者_C百科', '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);


Have you tried dropping the HTTP part from setSiteRestriction? Google documentation appears to use the convention setSiteRestriction("domain.com") without any protocol:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜