Javascript 我的谷歌图像搜索中没有图像

Javascript 我的谷歌图像搜索中没有图像,javascript,google-api,google-image-search,Javascript,Google Api,Google Image Search,好的,我想使用GoogleAPI进行图像搜索,我知道这是不推荐的,但我不想使用自定义搜索 这是我一直在使用的代码 <script type="text/javascript"> google.load('search', '1'); var imageSearch; function addPaginationLinks() { // To paginate search results, use the cursor function. var

好的,我想使用GoogleAPI进行图像搜索,我知道这是不推荐的,但我不想使用自定义搜索

这是我一直在使用的代码

<script type="text/javascript">

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

  var imageSearch;

  function addPaginationLinks() {

    // To paginate search results, use the cursor function.
    var cursor = imageSearch.cursor;
    var curPage = cursor.currentPageIndex; // check what page the app is on
    var pagesDiv = document.createElement('div');
    for (var i = 0; i < cursor.pages.length; i++) {
      var page = cursor.pages[i];
      if (curPage == i) { 

      // If we are on the current page, then don't make a link.
        var label = document.createTextNode(' ' + page.label + ' ');
        pagesDiv.appendChild(label);
      } else {

        // Create links to other pages using gotoPage() on the searcher.
        var link = document.createElement('a');
        link.href="/image-search/v1/javascript:imageSearch.gotoPage("+i+');';
        link.innerHTML = page.label;
        link.style.marginRight = '2px';
        pagesDiv.appendChild(link);
      }
    }

    var contentDiv = document.getElementById('content');
    contentDiv.appendChild(pagesDiv);
  }

  function searchComplete() {

    // Check that we got results
    if (imageSearch.results && imageSearch.results.length > 0) {

      // Grab our content div, clear it.
      var contentDiv = document.getElementById('content');
      contentDiv.innerHTML = '';

      // Loop through our results, printing them to the page.
      var results = imageSearch.results;
      for (var i = 0; i < results.length; i++) {
        // For each result write it's title and image to the screen
        var result = results[i];
        var imgContainer = document.createElement('div');
        var title = document.createElement('div');

        // We use titleNoFormatting so that no HTML tags are left in the 
        // title
        title.innerHTML = result.titleNoFormatting;
        var newImg = document.createElement('img');

        // There is also a result.url property which has the escaped version
        newImg.src="/image-search/v1/result.tbUrl;"
        imgContainer.appendChild(title);
        imgContainer.appendChild(newImg);

        // Put our title + image in the content
        contentDiv.appendChild(imgContainer);
      }

      // Now add links to additional pages of search results.
      addPaginationLinks(imageSearch);
    }
  }

  function OnLoad() {

    // Create an Image Search instance.
    imageSearch = new google.search.ImageSearch();

    // Set searchComplete as the callback function when a search is 
    // complete.  The imageSearch object will have results in it.
    imageSearch.setSearchCompleteCallback(this, searchComplete, null);

    // Find me a beautiful car.
    imageSearch.execute("Ferrari");

    // Include the required Google branding
    google.search.Search.getBranding('branding');
  }
  google.setOnLoadCallback(OnLoad);
</script>
但我不知道是否有其他网址我可以使用或我可以做什么

我不能在大学项目中使用JQuery,我们也不能使用JQuery

谢谢你的夸奖

变化

link.href="/image-search/v1/javascript:imageSearch.gotoPage("+i+');';

改变

newImg.src="/image-search/v1/result.tbUrl;"

改变

改变

newImg.src="/image-search/v1/result.tbUrl;"


自2011年5月26日起,谷歌图像搜索API已被正式弃用,显然已经完全停止


GimageSearch上的XHR调用返回
回调google.search.ImageSearch.RawCompletion('1',null,403',此API不再可用。',200)


您必须使用新的自定义搜索API:

自2011年5月26日起,谷歌图像搜索API已被正式弃用,显然已完全停止


GimageSearch上的XHR调用返回
回调google.search.ImageSearch.RawCompletion('1',null,403',此API不再可用。',200)


您必须使用新的自定义搜索API:

我在更新的(?“V1”中尝试了这种方法,但没有效果。我也看不到任何图像,他们举了一个“hello world”的例子来说明为什么会投反对票?应用上述更改后,代码将正常工作。如果更改对您没有任何影响,请提供您的代码。我在更新的(?“V1”中尝试了这一点,但没有效果。我也看不到任何图像,他们举了一个“hello world”的例子来说明为什么会投反对票?应用上述更改后,代码将正常工作。如果更改对您没有任何影响,请提供您的代码。您是否使用他们提供的id?我们复制和粘贴的一些代码有一个需要替换的通用id。我也有同样的问题。没有显示结果。当我显示日志时,
imageSearch.results
GimageSearch上的XHR调用返回
callback google.search.imageSearch.RawCompletion('1',null,403,'此API不再可用。',200)
我想我们不能使用此API您使用的是他们给您的id吗?我们复制和粘贴的一些代码有一个需要替换的通用id。我也有同样的问题。没有显示结果。当我显示日志时,
imageSearch.results
GimageSearch上的XHR调用返回
callback google.search.imageSearch.RawCompletion('1',null,403,'此API不再可用。',200)
我想我们不能使用此API
newImg.src="/image-search/v1/result.tbUrl;"
newImg.src=result.tbUrl;