利用 Java parse 網頁
URL url = null;
try {
url = new URL( address );
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
/**
* 因為在 tomcat 6 上是設定 big5
* 所以在此行需設定 utf-8 編碼
* 否則收到的內容會是亂碼
* 造成無法解析
*/
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream(), "UTF-8" ) );
String line = "";
while( ( line = in.readLine() ) != null ) {
if( line.contains( counterWording ) ) {
//System.out.println("line: " + line );
savePersonCounter(line );
}
}
in.close();
}
catch(MalformedURLException e ) {
System.out.println("連線失敗: " + e.toString() );
e.printStackTrace();
}
catch(IOException e ) {
System.out.println("WorkflowPersonCounter 執行失敗" );
e.printStackTrace();
}
URL url = null;
try {
url = new URL( address );
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
/**
* 因為在 tomcat 6 上是設定 big5
* 所以在此行需設定 utf-8 編碼
* 否則收到的內容會是亂碼
* 造成無法解析
*/
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream(), "UTF-8" ) );
String line = "";
while( ( line = in.readLine() ) != null ) {
if( line.contains( counterWording ) ) {
//System.out.println("line: " + line );
savePersonCounter(line );
}
}
in.close();
}
catch(MalformedURLException e ) {
System.out.println("連線失敗: " + e.toString() );
e.printStackTrace();
}
catch(IOException e ) {
System.out.println("WorkflowPersonCounter 執行失敗" );
e.printStackTrace();
}