본문 바로가기

프로그래밍/Android

jericho htmlparser - html 파서

html 안에 텍스트 받아오기

import java.net.URL;

import net.htmlparser.jericho.Source;

public class htmltotext {

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

Source source = null;

String text= null;

try {

source=new Source(new URL("http://google.com"));

source.fullSequentialParse();

//source.toString();

text=source.getTextExtractor().toString();

System.out.println(text);

} catch (Exception e) {

e.printStackTrace();

}

}

}

출력 결과 

---------------------------------------------------------------------------------------------------------

Google 검색 이미지 동영상 지도 뉴스 번역 도서 Gmail 더보기 ? iGoogle | 웹 기록 | 설정 | 로그인 한국   고급검색언어도구 광고 프로그램Google 정보Google.com in English ? 2012 - 개인정보 보호 및 약관