안드로이드 개발 질문/답변
(글 수 45,052)
package html.html;
import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList;
import net.htmlparser.jericho.Source; import android.app.Activity; import android.os.Bundle; import android.widget.TextView;
public class main extends Activity { /** Called when the activity is first created. */ //ListView list; TextView text; @SuppressWarnings("unchecked") ArrayList m_orders = new ArrayList(); @SuppressWarnings("unchecked") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); text=(TextView)findViewById(R.id.TextView01); String sourceUrlString="http://www.konkuk.ac.kr/do/MessageBoard/ArticleRead.do?forum=today&id=54f9af1"; String htmlContent =getHtmlToText(sourceUrlString); // htmlContent.split(" "); text.setText(htmlContent); } @SuppressWarnings("unchecked")
public String getHtmlToText(String sourceUrlString) { Source source = null; String content = null; try { URL url = new URL(sourceUrlString); InputStreamReader isr = new InputStreamReader(url.openStream(), "utf-8"); source = new Source(isr); source.fullSequentialParse(); content = source.getTextExtractor().toString(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return content; } }
특정 주소를 제리코 파서를 이용하여 파싱을 하였습니다.
그런데 어제는 파싱했을때 아무것도 스트링으로 넘어오지 않더니만..
오늘은 또다시 뜨네요;
물론 그 주소 홈피에 가봤는데 문제는 없었습니다.;;
저랑 같은 문제 있으신분 계신가요?;;
이런거는 해결하기도 난감하네여 ㅠㅠ