标签: google-custom-search

如何在Google搜索iframe上设置自定义宽度?

我正在尝试使用谷歌搜索我的网站:

http://www.houseofhawkins.com/search.php

某些屏幕分辨率并不好看.以下是谷歌提供的代码:

<div id="cse-search-results"></div>
<script type="text/javascript">
  var googleSearchIframeName = "cse-search-results";
  var googleSearchFormName = "cse-search-box";
  var googleSearchFrameWidth = 250;
  var googleSearchDomain = "www.google.com";
  var googleSearchPath = "/cse";
</script>
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>
Run Code Online (Sandbox Code Playgroud)

我将"googleSearchFrameWidth"更改为250认为应该在px中设置宽度,(以600开头).但是对于较小的屏幕(1024*768),它突出了我的div的一面.

我做了些蠢事吗?

google-search google-custom-search

6
推荐指数
2
解决办法
2万
查看次数

将变量传递给Google自定义搜索引擎

是否可以将搜索变量传递到我在网站上嵌入的Google自定义搜索引擎?我可以让搜索引擎工作,但我无法通过POST传递一个术语(它来自网站其他页面上的搜索按钮)

我试图破解我在这里找到的代码:http://code.google.com/apis/ajax/playground/?exp = search#hello_world

这就是我到目前为止......($ q是我传给它的术语)

<script type="text/javascript">
    google.load('search', '1', {language : 'en'});

    function OnLoad()
    {
        var customSearchControl = new google.search.CustomSearchControl('***my key****');
        customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
        customSearchControl.draw('cse');
        searchControl.execute("$q");
    }
    google.setOnLoadCallback(OnLoad);
</script>   
Run Code Online (Sandbox Code Playgroud)

谢谢

search-engine google-custom-search

6
推荐指数
1
解决办法
9459
查看次数

Java SSLException:证书中的主机名与www.googleapis.com不匹配

环境:Mac OS X Lion和Linux Debian squeeze/sid,JDK 1.7.0和JDK 1.6.0_27

错误:

javax.net.ssl.SSLException: hostname in certificate didn't match: <www.googleapis.com/74.125.47.95> != <*.googleapis.com> OR <googleapis.com> OR <*.googleapis.com> .
Run Code Online (Sandbox Code Playgroud)

我在所有上述OS/JDK组合中都收到此错误.

背景:我正在使用google-api-services-customsearch和google-api-service-shopping jar来向Google发送网络服务电话.我的电话一直工作到一天前.从昨天开始,代码开始抛出......

javax.net.ssl.SSLException: hostname in certificate didn't match: <www.googleapis.com/74.125.47.95> != <*.googleapis.com> OR <googleapis.com> OR <*.googleapis.com>
    at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:228)
    at org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify(BrowserCompatHostnameVerifier.java:54)
.....
    at com.google.api.services.shopping.Shopping$Products$List.execute(Shopping.java:156)
Run Code Online (Sandbox Code Playgroud)

我尝试cacerts使用此处的说明将证书导入密钥库,但这似乎无法解决问题.

java ssl google-api google-custom-search

6
推荐指数
1
解决办法
2万
查看次数

Google自定义搜索引擎如何解决XSS问题?

我一直在考虑使用Google CSE使用的类似方法构建服务 - https://developers.google.com/custom-search/docs/js/rendering 我无法理解Google如何解决这个问题XSS.是因为他们托管了他们能够写入DIV的JS文件吗?他们使用的是CORS标头吗?如果您有使用此模式的经验,请分享您的输入.

javascript xss jsonp cors google-custom-search

6
推荐指数
1
解决办法
562
查看次数

谷歌自定义搜索REST结果数量(num字段)

我正试图弄清楚如何强制谷歌自定义搜索每页给我20个结果.我尝试将此REST请求配置为我的新自定义搜索引擎:标准版:免费,结果页面上需要广告.

https://www.googleapis.com/customsearch/v1?key=AIzaSyCgGuZie_Xo-hOECNXOTKp5Yk7deryqro8&cx=015864032944730029962:5ipe0q27hgy&q=test&alt=json&num=20

它不起作用!

https://www.googleapis.com/customsearch/v1?key=AIzaSyCgGuZie_Xo-hOECNXOTKp5Yk7deryqro8&cx=015864032944730029962:5ipe0q27hgy&q=test&alt=json&num=10

有用!

但阅读文档

https://developers.google.com/custom-search/docs/xml_results#numsp

它说:

可选的.num参数标识要返回的搜索结果的数量.

默认的num值为10,最大值为20.如果请求的结果超过20,则只返回20个结果.

注意:如果搜索结果总数小于请求的结果数,则将返回所有可用的搜索结果.

有人遇到过这个问题吗?

PS:我也尝试将配置我的新自定义搜索引擎的REST请求发送到:网站搜索:每年100美元起,广告在结果页面上是可选的.

但是没有任何改变无法在请求/页面中获得20个结果

google-custom-search

6
推荐指数
1
解决办法
3113
查看次数

仅允许Google CSE并禁止在ROBOTS.txt中使用Google标准搜索

我有一个网站,我正在使用谷歌自定义搜索引擎.我希望Google CSE抓取我的网站,但我希望它不会出现常规Google搜索结果.我把它放在我的robots.txt文件中,希望google CSE机器人会忽略它,因为我指定了我希望Google CSE在设置中抓取的页面

User-agent: *
Disallow: /
Run Code Online (Sandbox Code Playgroud)

我猜Google CSE机器人也必须服从robots.txt.那么有没有办法让我的网页远离搜索引擎搜索,但谷歌CSE仍然可以索引它?TIA!

robots.txt google-custom-search

6
推荐指数
1
解决办法
713
查看次数

Google自定义搜索API会在不同的网页上返回不同的总结果

在Google自定义搜索API中,似乎在response.queries.request [0]对象中返回的"totalResults"字段在搜索结果的最后一页上减少.例如,如果搜索总共有17个结果,并且我发送了一个附加了"&start = 11"的相同请求,则"response.queries.request [0] .totalResults"的值从17下降到12.

我不确定是什么导致这种情况,或者它是否甚至在我的结尾(谷歌可能在事后过滤掉重复的条目吗?).

google-custom-search

6
推荐指数
1
解决办法
1996
查看次数

如何在Android应用中进行Google图片搜索

我正在开发一款可以进行Google图片搜索的Android应用,并将图片以列表形式返回给用户.我查看了stackoverflow并遇到了一些问题.首先,我是一名新手程序员,只有4个月的编程经验,所以我很感谢你们对我有耐心.

我查看了谷歌图片搜索API,我知道它正在折旧,有一天会被关闭.因此,我不想使用它.经过对该主题的广泛研究,我不想使用Bing或其他图像搜索服务,我不想进行"反向图像搜索.我只想通过字符串使用简单的图像搜索.我'我使用这个应用程序(https://github.com/tonytamsf/Android-Image-Search)来查看代码,但说实话,它只是没有帮助,这让我更加困惑如何在上面搜索图像谷歌.此外,该应用程序将无法在Eclipse中编译:(

我也查看了Google Developer API,我不确定是否需要为自己打开API密钥?对此仍然有点困惑.我以为我需要做一个自定义搜索引擎,但仅仅通过观察,我不认为这正是我正在寻找的.

有人能指点我一些资源吗?我真的很感激.谢谢!

android google-api google-custom-search google-image-search

6
推荐指数
1
解决办法
1万
查看次数

Google自定义搜索:iOS中的403错误

谷歌自定义搜索从我的iPhone 7.1应用程序返回此403错误.这是在模拟器中运行时的响应:

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
   }
  ],
  "code": 403,
  "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
 }
}
Run Code Online (Sandbox Code Playgroud)

下面的步骤有缺陷吗?我想建立一个针对iOS应用程序的工作CSE设置过程.每一步的屏幕截图都有望帮助而不是混淆!

  1. 通过https://www.google.com/cse/创建自定义搜索引擎(CSE)

  2. 从设置 - >基础知识,获取搜索引擎ID. CSE搜索引擎ID

  3. 通过https://developers.google.com/apis-explorer/#p/customsearch/v1/search.cse.list测试CSE

    • 在步骤2中将"q"设置为搜索引擎ID的任何测试查询字词("foo bar")和"cx".
    • 按"执行"并接收搜索结果.他们工作.Google还提供了此网址,我们将在第8步中在Xcode中重复使用该网址. Google API Explorer测试结果
  4. 要获得ID和计费目的的密钥,请通过以下网址创建新项目:https://console.developers.google.com/

  5. 在API&auth - > API - >启用"自定义搜索API".没有启用其他API. 开发者控制台API

  6. 在API&auth - >凭据 - >创建新的iOS密钥. 开发者控制台凭据 注意:我还尝试了浏览器密钥,搜索结果返回"错误400:无效值".我回到iOS键,因为我在iOS上,错误似乎不那么严重.

  7. 从Xcode添加此密钥标识符. …

search-engine google-api ios google-custom-search

6
推荐指数
1
解决办法
5802
查看次数

Google附加链接搜索框,带有Google自定义搜索功能

我们希望使用Google自定义搜索来实施Google附加链接搜索框.在Google 文档中,我发现我们需要包含以下代码才能启用附加链接搜索框

    <script type="application/ld+json">
{
   "@context": "http://schema.org",
   "@type": "WebSite",
   "url": "https://www.example-petstore.com/",
   "potentialAction": {
     "@type": "SearchAction",
     "target": "https://query.example-petstore.com/search?q={search_term_string}",
     "query-input": "required name=search_term_string"
   }
}
</script>
Run Code Online (Sandbox Code Playgroud)

但是我们仍然停留在上述属性中的"目标"节点.由于我们没有自己的搜索页面,我们希望使用Google自定义搜索,因此我应该在这个"目标"节点中填写什么值.

我们已经为我们的网站创建了一个Google自定义搜索引擎.并在下面找到代码

<script>
  (function() {
    var cx = 'CX_ID';
    var gcse = document.createElement('script');
    gcse.type = 'text/javascript';
    gcse.async = true;
    gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
        '//www.google.com/cse/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
  })();
</script>
<gcse:search></gcse:search>
Run Code Online (Sandbox Code Playgroud)

我们想实现像Mashable,Imdb这样的附加链接搜索框

在此输入图像描述

请建议,如何在附加链接搜索框代码中指向Google自定义搜索.

谢谢

google-search-api google-custom-search google-oauth

6
推荐指数
1
解决办法
1652
查看次数