Google自定义搜索API按图搜索图像

时间:2015-02-09 13:38:42

标签: java android json google-custom-search google-image-search

我可以使用Google自定义搜索引擎从Json格式的java项目中获取图像结果。然后我从Json文件中获取图像链接,并显示来自Android应用程序的图像。我想以某种方式过滤我显示给我的Android应用程序的内容。

所以我想通过图片网址搜索图片,并以Json格式获得类似的图片结果。我知道Google图片搜索API,但已被弃用。我也知道tineye api,但它需要付款,我更喜欢开源。

有没有办法按图片网址搜索图片并以Json格式获取结果?

1 个答案:

答案 0 :(得分:1)

确切地不确定您的问题 - 但谷歌自定义搜索引擎可以返回图片结果:例如仅用于java

的搜索查询的文件类型.png的结果
String newURL = "https://www.googleapis.com/customsearch/v1?key=<YOUR API KEY>&cx=<your google custom search engine>&q=java&as_filetype=png";

// Create a new RestTemplate instance
RestTemplate restTemplate = new RestTemplate();

// Add the String message converter
restTemplate.getMessageConverters().add(new StringHttpMessageConverter());

// Make the HTTP GET request, marshaling the response to a String
String googleRestResult = restTemplate.getForObject(newURL, String.class, "Android");

查看详情 https://developers.google.com/custom-search/docs/xml_results#startsp