package com.dw.lib.test;

import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.*;
import org.jsoup.select.Elements;
public class jsoupTest {
	
	public static void printByClass(Document doc, String className) {
		Elements e = doc.getElementsByClass(className);
		String output = e.toString();
		if(output.equals("")) return;
		
		System.out.println(jtidyTest.html2text(e.toString()));
	}
	
	public static void printUsage() {
		System.out.println("jdict [word list]");
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			
			if(args.length <= 0) {
				printUsage();
			}
			
			//String word = args[0];
			
			String[] className = {"dict-basic-ul", 
					"layout detail", 
					"layout dual",
					"layout en", 
					"layout sort",
					"layout anno",
					"layout auth",
					"layout nfo",
					"layout nwd"
					};

			for (int i = 0; i < args.length; i++) {
				System.out.println(String.format("%s: ", args[i]));

				Document doc = Jsoup.connect(String.format("http://dict.cn/%s", args[i])).get();
				for (String s : className)
					printByClass(doc, s);
			}
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

@@ -226,16 +226,25 @@
 Name) %7B%0A
+%09%09try %7B%0A%09
 %09%09Elemen
@@ -287,16 +287,17 @@
 ame);%0A%09%09
+%09
 String o
@@ -318,20 +318,22 @@
 ring();%0A
+%09
 %09%09if
+ 
 (output.
@@ -347,17 +347,21 @@
 %22%22))
- 
+%0A%09%09%09%09
 return;%0A
 %09%09%0A%09
@@ -356,19 +356,18 @@
 return;%0A
-%09%09
 %0A
+%09
 %09%09System
@@ -403,23 +403,101 @@
 ext(
-e.to
+new 
 String(
-)));
+output.getBytes(%22UTF-8%22))));%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D
 %0A%09%7D%0A

change to utf-8 encoding