HTML Extraction Tool htmlparserhtmlparser

Source: Internet
Author: User

For HTML extraction, I believe many people have heard of or used htmlparser.

Htmlparser is a pure library written in Java for HTML Parsing. It is not dependent on other Java library files and is mainly used to transform or extract HTML. It cannot be said that it can parse HTML at a high speed, but its resolution quality is good and it is not prone to errors. To put it bluntly, htmlparser is currently the most powerful Java HTML parsing and analysis tool.

Htmlparser Project Website: http://htmlparser.sourceforge.net /.

For more information about how to get started with htmlparser, see the blog "Introduction to htmlparser". Of course, you can also refer to htmlparser learning and htmlparser usage.

The following is a simple htmlparser example for reading all the text on an HTML page.

 1   Package  Org.html parser;  2   Import  Java. Io. file;  3   Import Java. Io. fileoutputstream;  4   Import  Org.html parser. parser;  5   Import  Org.html parser. lexer. cursor;  6   Import  Org.html parser. nodes. tagnode;  7   Import  Org.html parser. util. nodeiterator;  8   Import Org.html parser. util. nodelist;  9   10   Public   Class  Simplehtmlparse {  11       Public   Static   Void Main (string ARGs []) Throws  Exception {  12       13 Parser = New Parser ("d :\\ html1.htm");  14              //  Parser = new Parser ("I: \ bbb.htm ");  15 Parser. setencoding ("GBK" );  16 Nodelist list = parser. parse ( Null  );  17 String STR = List. tostring ();  18   System. Out. println (STR );  19            20 Fileoutputstream output = New Fileoutputstream ( New File ("d :\\ 1.txt" ));  21                 Byte B [] = Str. getbytes ();  22              For ( Int  I: B ){  23   Output. Write (I );  24  }  25   Output. Close ();  26   }  27 }

 

In fact, there will be a lot of gains for in-depth research on HTML parsing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.