에러 많이 터짐;; 이유를 잘 몰곘음;;
import java.io.BufferedInputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class GetTitle {
public static final int buffer_size = 18*1024;
public static void main(String[] args) {
try{
URL url = new URL("http://naver.com");
HttpURLConnection comm = (HttpURLConnection) url.openConnection();
comm.connect();
byte[] user_buffer = new byte[buffer_size];
BufferedInputStream bis = new BufferedInputStream(comm.getInputStream(), 1024);
String s;
while(true) {
if(bis.read(user_buffer, 0, user_buffer.length) == -1) {
s = new String(user_buffer,"UTF8");
break;
}
else
s = new String(user_buffer,"UTF8");
if(s.indexOf("<dt id=\"rankTitle\">")!=-1){
System.out.println(s.indexOf("<dt id=\"rankTitle\">"));
System.out.println(s.substring(s.indexOf("<dt id=\"rankTitle\">"),s.indexOf("<form action=\"http://search.naver.com/search.naver\">")));
}
user_buffer = new byte[buffer_size];
}
bis.close();
comm.disconnect();
} catch(Exception e)
{
네이버에 웹마스터도구에서 rss요청을 방금함.. (0) | 2015.02.21 |
---|---|
jsp 게시판 화면단 한개 받음 (0) | 2015.02.18 |
자바스크립트 글자 하나씩 나왔다가 사라지기 (0) | 2015.02.17 |
jsp 답변형 게시판 만들기... 4일차...jsp도 4일차.... (0) | 2015.02.17 |
jsp 답변형 게시판 java 부분 (0) | 2015.02.17 |