标签: google-search-api

如何使用api获取所有谷歌搜索结果

我需要获取谷歌搜索结果进行查询.但是使用这样的东西

$query = 'Nikita Platonenko';
$url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=".urlencode($query);
$body = file_get_contents($url);
$json = json_decode($body);
var_dump($json)
Run Code Online (Sandbox Code Playgroud)

我只得到了4个结果,我已经读过谷歌ajax搜索,但无法理解.请告知如何获得所有结果,或只是前100个结果?

php google-search-api

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

Google custom search for images only

Since Google image search API is deprecated, one should use Google custom search API for this.

I've made a small example using it. My problem is I want to return google image search results only. Whereby this shows web results, and the user may switch to the image result. How can I show only the image results by default?

<div id="cse" style="width: 100%;">Loading</div>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
  google.load('search', '1', {language : 'hu'});
  google.setOnLoadCallback(function() {
    var customSearchOptions = { …
Run Code Online (Sandbox Code Playgroud)

javascript google-search-api google-image-search

19
推荐指数
3
解决办法
4万
查看次数

通过Java中的Google Custom Search API V1获得超过10个结果

我在Java中使用Google Custom Search API来获取Google的结果以响应查询.我在其他帖子的帮助下编写了这段代码,代码如下:

    url = new URL("https://www.googleapis.com/customsearch/v1?key="+key+ "&cx="+ cx +"&q="+    searchText+"&alt=json"+"&start="+0+"&num="+30);
    HttpURLConnection conn2 = (HttpURLConnection) url.openConnection();
    System.out.println("Connection opened!");
    conn2.setRequestMethod("GET");
    conn2.setRequestProperty("Accept", "application/json");
    BufferedReader br = new BufferedReader(new InputStreamReader(
    (conn2.getInputStream())));
Run Code Online (Sandbox Code Playgroud)

问题是,每当我使用上面的代码而没有num和start参数时,它正在正确执行,但只给出前10个结果.所以我使用了num和start参数.但他们正在制造问题.在这里,我无法理解将numstart参数放在url中的位置.它始终提供HTTP 400即错误请求.我已经阅读了"文档"页面,也没有明确说明将这两个参数放在Url中的位置.

所以,如果有人帮助我解决这个问题,我将非常感激.谢谢.

java google-search-api

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

Jersey rest客户端不添加查询参数

我正在尝试为谷歌搜索API制作一个简单的球衣休息客户端.

Client client = ClientBuilder.newClient();
WebTarget target = client.target("https://www.googleapis.com/customsearch/v1");
target.queryParam("q", "mobile");
Response response = target.request().get();
System.out.println(response.readEntity(String.class));
Run Code Online (Sandbox Code Playgroud)

你已经注意到我没有包括keycx.不用担心,这只是一个简单的演示.访问网址时https://www.googleapis.com/customsearch/v1?q=mobile,回复是

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "dailyLimitExceededUnreg",
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
    "extendedHelp": "https://code.google.com/apis/console"
   }
  ],
  "code": 403,
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
 }
}
Run Code Online (Sandbox Code Playgroud)

这是正确的,因为我没有包括keycx.当我执行上面的代码时,我得到的响应是

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "required",
    "message": "Required …
Run Code Online (Sandbox Code Playgroud)

java rest client jersey google-search-api

15
推荐指数
1
解决办法
9087
查看次数

以编程方式搜索谷歌(或其他)搜索结果的数量

我正在制作一个小小的个人项目.理想情况下,我希望能够以编程方式进行谷歌搜索,并计算结果.(我的目标是比较不同短语(100000+)之间的结果数).

有没有一种免费的方式来进行网络搜索并比较popularity不同的文本,使用谷歌Bing或其他(来源不是很重要).

我试过谷歌,但似乎自由我每天只能做10个请求.Bing更宽松(每月5000个免费请求).

是否有其他工具或方法可以自由计算特定句子的结果数?提前致谢.

google-search-api bing-api

15
推荐指数
1
解决办法
511
查看次数

如何使用google customsearch API查询高级搜索?

如何使用Google Python客户端库以编程方式使用Google自定义搜索API搜索引擎进行高级搜索,以便n根据我查询的高级搜索的某些术语和参数返回第一个链接列表?

我试图检查文档(我没有找到任何例子),这个答案.但是,后者没有用,因为目前不支持AJAX API.到目前为止我试过这个:

from googleapiclient.discovery import build
import pprint

my_cse_id = "test"

def google_search(search_term, api_key, cse_id, **kwargs):
    service = build("customsearch", "v1",developerKey="<My developer key>")
    res = service.cse().list(q=search_term, cx=cse_id, **kwargs).execute()
    return res['items']

results = google_search('dogs', my_api_key, my_cse_id, num=10)

for result in results:
    pprint.pprint(result)
Run Code Online (Sandbox Code Playgroud)

还有这个:

import pprint

from googleapiclient.discovery import build


def main():
  service = build("customsearch", "v1",developerKey="<My developer key>")

  res = service.cse().list(q='dogs').execute()
  pprint.pprint(res)

if __name__ == '__main__':
  main()
Run Code Online (Sandbox Code Playgroud)

因此,任何关于如何使用谷歌的搜索引擎API进行高级搜索的想法?这就是我的凭据在Google控制台上的显示方式:

证书

python google-api google-search-api python-3.x google-api-python-client

13
推荐指数
1
解决办法
2615
查看次数

ModuleNotFoundError:没有名为“ google.appengine”的模块

我想在Windows上的python3中进行Google搜索。谷歌的说明说,他们支持python3并键入“ gcloud topic init”以获取详细信息-但这未能说明没有python2.7的解释器。我是否必须安装python2.7才能了解如何使其在python3上正常工作?

在python3上,我收到如下错误消息。我已经设置了API密钥和自定义搜索引擎。我做了“ pip install google-api-python-client”。我下载并运行了GoogleCloudSDKInstaller。这是错误:

from googleapiclient.discovery import build
service = build("customsearch", "v1", developerKey="xxxxxx")
Run Code Online (Sandbox Code Playgroud)

我得到:

[googleapiclient.discovery_cache:WARNING]:file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth (__init__.py:44, time=Apr-07 17:25) Traceback (most recent call last):   File "C:\Users\simon\Anaconda3\lib\site-packages\googleapiclient\discovery_cache\__init__.py", line 36, in autodetect
    from google.appengine.api import memcache ModuleNotFoundError: No module named 'google.appengine'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "C:\Users\simon\Anaconda3\lib\site-packages\googleapiclient\discovery_cache\file_cache.py", line 33, in <module>
    from oauth2client.contrib.locked_file import LockedFile ModuleNotFoundError: No module named 'oauth2client' …
Run Code Online (Sandbox Code Playgroud)

python google-app-engine google-search-api python-3.x google-custom-search

13
推荐指数
1
解决办法
2100
查看次数

从谷歌获取第一张图片

我想在我的网站上针对关键字在谷歌搜索中显示第一张图片.我真的很喜欢这方面的一些指示.

谢谢!

javascript image google-search google-search-api

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

Google CustomSearch会忽略imgType吗?

似乎使用谷歌CSE API总是忽略我的imgType属性,即使通过他们的官方API测试页面.

我的要求是:

{
    "q": "Maimi Yajima",
    "cx": "014585077406021600032:tu4nwhtmr5q",
    "searchType": "image",
    "imgType": "clipart"
}
Run Code Online (Sandbox Code Playgroud)

但即使改变imgType我总是得到相同的结果.

我哪里错了?

face-detection google-search-api

11
推荐指数
1
解决办法
190
查看次数

Google App Engine(python):搜索API:字符串搜索

我正在使用Google App Engine搜索API(https://developers.google.com/appengine/docs/python/search/).我已将所有实体编入索引,搜索工作正常.但只有当我搜索完全匹配时,它才会返回0结果.例如:

from google.appengine.api import search

_INDEX_NAME = 'searchall'


query_string ="United Kingdom"
query = search.Query(query_string=query_string)
index = search.Index(name=_INDEX_NAME)

print index.search(query)
Run Code Online (Sandbox Code Playgroud)

如果我运行以下脚本,我会得到如下结果:

search.SearchResults(results='[search.ScoredDocument(doc_id='c475fd24-34ba-42bd-a3b5-d9a48d880012', fields='[search.TextField(name='name', value='United Kingdom')]', language='en', order_id='45395666'), search.ScoredDocument(doc_id='5fa757d1-05bf-4012-93ff-79dd4b77a878', fields='[search.TextField(name='name', value='United Kingdom')]', language='en', order_id='45395201')]', number_found='2')
Run Code Online (Sandbox Code Playgroud)

但是,如果我改变query_string"United Kin""United"它返回0结果如下:

search.SearchResults(number_found='0')
Run Code Online (Sandbox Code Playgroud)

我想将此API用于普通搜索和AutoSuggest.实现这一目标的最佳方法是什么?

google-app-engine full-text-search google-search-api

10
推荐指数
1
解决办法
3255
查看次数