An error occurred while using htmlparser.
Org.html parser. util. parserexception: Error in opening a connection
Java. Io. ioexception: invalid argument
At java. Io. winntfilesystem. canonicalize0 (native method)
At java. Io. win32filesystem. canonicalize (win32filesystem. Java: 396)
At java. Io. file. GetCanonicalPath (file. Java: 559)
At org.html parser. http. connectionmanager. openconnection (connectionmanager. Java: 774)
At org.html partser. parser. <init> (parser. Java: 304)
At org.html partser. parser. <init> (parser. Java: 316)
At tentsoft. util. cnlinkinfparser. docnlinkinfparser (cnlinkinfparser. Java: 62)
At tentsoft. util. cnlinkinfparser. getcnlinklist (cnlinkinfparser. Java: 111)
At tentsoft. util. cnlinkinfparser. Main (cnlinkinfparser. Java: 138)
View carefullySource code, Found in
Myparser = new Parser (htmlbody); this sentence has an error
The htmlbody is the response obtained from a request to a website. The type is string.
But an error is reported.
Finally, define a method
/**
* Parse strings
* @ Param inputhtml string
* @ Return parser
*/
Public static parser createparser (string inputhtml ){
Lexer mlexer = new lexer (New Page (inputhtml ));
Return new Parser (mlexer,
New defaultparserfeedback (defaultparserfeedback. Quiet ));
}
Create new Parser () in createparser.
Solve the problem. The above myparser = new Parser (htmlbody) Statement is changed to myparser = createparser (htmlbody ).
this article from the csdn blog, reprint please indicate the source: http://blog.csdn.net/rudyMatrix/archive/2007/11/18/1891663.aspx