[Java] HTML Parsing

Source: Internet
Author: User

I. jsoup (I am not familiar with this class library due to direct first push)

English document: http://www.open-open.com/jsoup/parsing-a-document.htm

Jsoup use: http://www.iteye.com/topic/1010581

The simplest and practical: http://hongmin118.iteye.com/blog/1229705

/*** Parse an HTML string and get only the text in this string * @ Param HTML * @ return */public static string html2txt (string HTML) {// <span style = "color: RGB (229, 51, 51); background-color: RGB (0,153, 0); font-weight: bold; font-style: italic; text-Decoration: underline; "> Test 1 </span> document = jsoup. parse (HTML); string content = document. text (); Return content ;}

Your own code:

// Read all the text in HTML, without tags // data can be incomplete HTML page data document DOC = jsoup. parse (data); text = Doc. text (); // obtain all image tags media = Doc. select ("IMG [SRC]"); // obtain the link of the tag string imgurl = SRC. ATTR ("ABS: SRC ");

 

Ii. htmlparser

Use: http://free0007.iteye.com/blog/1131163

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.