📄 clientgoogle.java
字号:
package com.google.api;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
public class ClientGoogle
{
public static void main(String[] args) throws ServiceException, RemoteException
{
String clientKey = "ABQIAAAAyWZIuft2g4m5MR8rjp3nexTwM0brOpm-All5BF6PoaKBxRWWERQag3A4w5pZyCnUXhT_yBwaIO3oIA";
GoogleSearchServiceLocator service = new GoogleSearchServiceLocator();
GoogleSearchPort_PortType gsp = service.getGoogleSearchPort();
//Google Search API
GoogleSearchResult searchResult = gsp.doGoogleSearch(clientKey, "www.williamlong.info", 0, 10, false, "", false, "", "latin1", "latin1");
System.out.println("Google Search Results:");
System.out.println("======================");
ResultElement results[] = searchResult.getResultElements();
for (int counter = 0; counter < results.length; ++counter)
{
ResultElement result = results[counter];
String returnResult = "('" + result.getTitle() + "','" + result.getURL() + "','" + result.getSnippet() + "')";
System.out.println("Return Result");
System.out.println(returnResult);
}
//Google CachedPage
byte[] cachedBytes = gsp.doGetCachedPage(clientKey, "http://www.williamlong.info/");
System.out.println("Cached page:");
System.out.println("============");
String cachedString = new String(cachedBytes);
System.out.println(cachedString);
//Google SpellingSuggestion
String suggestion = (String) gsp.doSpellingSuggestion(clientKey, "williamlong");
System.out.println(suggestion); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -