Core Code
A package that needs to be introduced: Jxl-2.6.jar;
Source Package for content extraction: Jsoup-1.10.2.jar
-Read TXT file
FIS = new FileInputStream (
"C:\\users\\administrator\\desktop\\app3\\123.txt");
FileInputStream gets the byte
ISR = new InputStreamReader (FIS) from a file in the file system;//InputStreamReader is the bridge of byte flow to character stream,
br = The new BufferedReader (ISR);//reads the contents of the file from the character input stream, encapsulating a new
//InputStreamReader object while
(str = br.readline ())!= NULL) {}//here corresponds to each line of TXT, processing data
Writing to Excel
Writableworkbook book = Workbook.createworkbook (New File ("401-500.xls"));
Generates a worksheet named "first page", and parameter 0 indicates that this is the first page
writablesheet sheet = book.createsheet ("First page", 0);
Label Templabel = new label (0, 0, "test");
Add a defined cell to the worksheet
Sheet.addcell (Templabel);
Jsoup Content Matching
Document doc = Jsoup
. Connect (URL)
. Cookie ("Phpsessid", "prl7rupp8fud19iil04qod1886")
. Cookie ("token", "92a63634-e8b1-49db-acbf-4fac2bfcf44a")
. Cookies ("account_id", "173057768"). Timeout (30000). get ();
Processing of document
Elements es = Doc.select ("div.qa_list > Div.qa_item");
if (es.size () > 0) {for (int j = 0; J < Es.size (); j + +) {String s = es
. Get (j). Select ("div.qa_question_list > Div.qa_question > Input") . attr ("value")//property value in Content + "---" + es.ge
T (j). Select ("DIV.QA_ANSWER_BG > Div.qa_answer")
The text value WriteToFile (file, S, append) in the label. }
}