Google Custom Search API
如何使用JAVA使用Google Custom Search API? Google Search Appliance API的适当用途是什么?
这是谷歌自定义搜索API示例。 你需要下载库,例子就在这里
public class Custom { public static void main(String args[]) throws IOException { String key="Replace with your API key"; String qry="batman";// search key word URL url = new URL( "https://www.googleapis.com/customsearch/v1? key="+key+"&cx="Replace with unique ID"&q="+ qry + "&alt=json"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept", "application/json"); BufferedReader br = new BufferedReader(new InputStreamReader( (conn.getInputStream()))); String output; System.out.println(url); System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { if(output.contains("\"link\": \"")){ String link=output.substring(output.indexOf("\"link\": \"")+ ("\"link\": \"").length(), output.indexOf("\",")); System.out.println(link); } } conn.disconnect(); } }
- 不应命名Cloud Endpoint参数
- 问题com.google.gdata.util.ResourceNotFoundException:Google Analytic无法找到
- Java SSLException:证书中的主机名与www.googleapis.com不匹配
- 如何在日历Api中禁用Google的“video通话”默认设置?
- 当我尝试初始化GoogleMap对象时,我得到一个NullPointerException
- 如何使用服务帐户创建Google电子表格并与java中的其他Google用户共享?
- Google Admin SDK目录API(Java)中的members.list()
- 授权谷歌日历api适用于个人帐户,但不适用于谷歌域帐户
- 从Oauth2 Google Contacts API获取Userinfo