package com.application.pgm;


import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.net.HttpURLConnection;

import java.net.MalformedURLException;

import java.net.URL;


/**

 * urlList.txt 목록의 URL을 순회 하면서 원하는 텍스트를 찾아낸다. 

 * @author hana

 *

 */


public class UrlTest {


public static void main(String[] args) {

// TODO Auto-generated method stub


FileReader fr = null;

String url = "";

URL u = null;

HttpURLConnection conn = null;

int resCode = 0;

try {

fr = new FileReader("D:\\dev\\urlList.txt");

BufferedReader list_br = new BufferedReader(fr);

String list_Line = "";

while((list_Line = list_br.readLine()) != null){

url = list_Line;

u = new URL(url);

conn = (HttpURLConnection)u.openConnection();

resCode = conn.getResponseCode();

String ln = "";

if(resCode == 200){

BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8"));

while((ln=br.readLine()) != null){

if(ln.indexOf(".hanatour.com") > -1){

System.out.println("## Source Find !! ##  :: url :" + url);

System.out.println("## find String !! ##  :: str :" + ln);

System.out.println("------------------------------------");

}

}

}else{

System.out.println("########## WebSite Open Error!!##################");

System.out.println("#"+url+"#");

System.out.println("-------------------------------------------");

}

}

} catch (MalformedURLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}


}



+ Recent posts