当前位置: 动力学知识库 > 问答 > 编程问答 >

parsing - How to parse text from web content in java?

问题描述:

i would like to parse web content and get only text from the web content. I am getting web content as HTML/java script. Now i need only text from the content.

Can some one help me in doing this? I am using HTML parser to do this.

For example i need the text content in the below file which is in bold.

The URLConnection class contains many methods that let you communicate with

the URL over the network. URLConnection is an HTTP-centric class; that

is, many of its methods are useful only when you are working with HTTP

URLs. However, most URL protocols allow you to read from and write to

the connection. This section describes both functions.

can some one suggest me or provide some sample code to do this.

Thanks in Advance.

网友答案:

You could use an Html parser. A safe choise will be HtmlParser.

网友答案:

An unorthodox method that i like to use is tools like HtmlUnit, which is basically for unit testing, but they have advanced xpath parsing capabilities, provides automatic login, session handling kind of capabilities too.

网友答案:

I recommend use HtmlUnit for web download and Jsoup as html/xml parser.

I use them to extract infos from websites (Google search too).

分享给朋友:
您可能感兴趣的文章:
随机阅读: