import java.io.*;
import java.net.*;public class GoogleAJAXSearchAPI {
private static String endpointURL = "http://www.google.com/uds/GwebSearch?"+
"callback=GwebSearch.Raw" +
"Completion&context=0&lstkp=0&rsz=small&hl=en&" +
"sig=8656f49c146c5220e273d16b4b6978b2&q=Axis2&key=xxxxxxxxxxxxxxxxxx&v=1.0";public static void main(String[] args) throws Exception {
URLConnection uc = new URL(endpointURL).openConnection();
HttpURLConnection connection = (HttpURLConnection) uc;
connection.setDoOutput(true);
connection.setRequestMethod("GET");
connection.connect();
String line;
InputStream inputStream = null;
try {
inputStream = connection.getInputStream();
} catch (IOException e) {
inputStream = connection.getErrorStream();
}
BufferedReader rd = new BufferedReader(new InputStreamReader(inputStream));
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
}
'자바'에 해당되는 글 1건
- 2007.01.18 자바에서 Google AJAX 검색 API를 호출하는 방법
인터넷2007.01.18 23:45
구글 AJAX 검색 API를 자바에서 호출하는 방법이다.