구글 AJAX 검색 API를 자바에서 호출하는 방법이다.

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);
        }
    }
}

Creative Commons License
손가락 버튼을 눌러주시면 많은 분들과 내용을 공유할 수 있습니다.
Posted by 에버리치

트랙백 주소 : http://www.namuk.com/trackback/85 관련글 쓰기

댓글을 달아 주세요

졸업작품을 하나 만들려고 하니 급하게 이것 저것 알아야 할게 너무 많이 생겨버렸다.
일단은 AJAX부터 시작인데...

AJAX란 무엇인가, 어떻게 구현하는가에 대한 내용이 담겨 있는 강좌가 있다.

열심히 해야겠다.

  • Ajax 마스터하기, Part 1: Ajax 소개 (한글)
  • Ajax 마스터하기, Part 2: JavaScript와 Ajax를 이용한 비동기식 요청 (한글)
  • Ajax 마스터하기, Part 3: Ajax의 고급 요청 및 응답 (한글)
  • Ajax 마스터하기, Part 4: 웹 응답에 DOM 활용하기 (한글)
  • Ajax 마스터하기, Part 5 : DOM 다루기 (한글)
  • Ajax 마스터하기, Part 6: DOM 기반 웹 애플리케이션 구현 (한글)
  • Ajax 마스터하기, Part 7: 요청과 응답에 XML 사용하기 (한글)
  • Ajax 마스터하기, Part 8: 요청과 응답에 XML 사용하기 (한글)
  • Creative Commons License
    손가락 버튼을 눌러주시면 많은 분들과 내용을 공유할 수 있습니다.
    Posted by 에버리치

    트랙백 주소 : http://www.namuk.com/trackback/81 관련글 쓰기

    댓글을 달아 주세요

    1. 2007/01/18 12:18  댓글주소  수정/삭제  댓글쓰기

      비밀댓글입니다