【问题标题】:google search api not giving results谷歌搜索api没有给出结果
【发布时间】:2009-12-30 11:45:10
【问题描述】:

我在网站中使用 Google Search API 从网站生成结果。(the site) 问题是,它根本没有生成结果。如果我将站点限制更改为其他站点(例如 wikipedia.org 或任何其他站点),它会产生结果。

并不是没有列出该网站 - 当我在 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);

【问题讨论】:

  • 您能否详细介绍一下您是如何拨打电话的?例如,调用的确切代码行会很有帮助
  • @james:这是你要求的,还是我发错了部分?

标签: asp.net api search


【解决方案1】:

您是否尝试过从 setSiteRestriction 中删除 HTTP 部分? Google 文档似乎使用约定 setSiteRestriction("domain.com") 而没有任何协议:

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

【讨论】:

  • 我是否遗漏了一些明显的东西..?
猜你喜欢
  • 1970-01-01
  • 2012-04-21
  • 1970-01-01
  • 2012-04-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多