java open api 파싱한 것중에서 원하는 정보만 출력하고 싶은데 어떻게 해야하나요
조회수 2638회
import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL;
@SuppressWarnings("unused") public class Web_Parser_Default {
private static final String USER_AGENT = "Mozilla/5.0";
private String Address;
private URL Url;
private BufferedReader br;
private HttpURLConnection con;
private String protocol = "GET";
public Web_Parser_Default() throws Exception
{
Address = "http://whois.kisa.or.kr/openapi/whois.jsp?query=kisa.or.kr&key=xxxx";
Url = new URL(this.Address);
con = (HttpURLConnection)Url.openConnection();
con.setRequestMethod(protocol);
con.setRequestProperty("User-Agent", USER_AGENT);
br = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
String line;
while((line = br.readLine()) != null)
{
System.out.println(line);
}
br.close();
}
public static void main(String[] args) throws Exception{
Web_Parser_Default w = new Web_Parser_Default();
}
}
제가 whois open api를 파싱했는데 결과값이 이렇게 떠요
근데 여기서 regName과 adminEmail, ip1부분만 출력되게 하고 싶은데 어떻게 해야할지 모르겠어요ㅠㅠ 어떤 소스를 추가해야하는건지 좀 알려주세요
-
(•́ ✖ •̀)
알 수 없는 사용자
1 답변
-
응답 결과를 xml로 파싱하고, 파싱된 xml document 객체에서 원하는 node만 찾아 출력하면 됩니다.
http://www.journaldev.com/1240/java-xml-tutorial
여기를 참고하세요.
댓글 입력