Jsoup解析Html标签(Java后台解析)

  

  中文API网站(下载地址): http://www.open-open.com/jsoup/ 

  有时候编辑器传到后台的内容是带Html标签的,或者有时候需要形成一个完整的Html文档,也或者需要解析其中的文字(text()),Java后台处理用Jsoup非常方便,也可以用选择器快速获取元素,类似于jQuery。获取到文档对此之后对其处理与JS处理DOM一样方便,选取元素也类似于JS,也有类似于jQuery的语法,官方的解释

1.最基本的解析Html字符串

    @Test
    public void testHtmlToString2() {
        String html = "<p>这是一个段落<img src=\"test.img\"/>内容;</p>";
        Document doc = Jsoup.parse(html);
        System.out.println(doc); // 输出带标签的html文档
        System.out.println("---------------------\n"+doc.text()); // 输出内容
        Elements element = doc.getElementsByTag("p");
        System.out.println("---------------------\n"+element.get(0).html());
    }

结果:

<html>
 <head></head>
 <body>
  <p>这是一个段落<img src="test.img">内容;</p>
 </body>
</html>
---------------------
这是一个段落内容;
---------------------
这是一个段落<img src="test.img">内容;

2.解析字符串

    // 解析html字符串
    @Test
    public void testHtmlToString() {
        String html = "<html><head><title>First parse</title></head>"
                + "<body><p style=‘center‘>Parsed HTML into a doc.</p></body></html>";
        Document doc = Jsoup.parse(html);
        System.out.println(doc); // 输出带标签的html文档
        System.out.println("---------------------\n"+doc.text()); // 输出内容
    }

结果:

<html>
 <head>
  <title>First parse</title>
 </head>
 <body>
  <p style="center">Parsed HTML into a doc.</p>
 </body>
</html>
---------------------
First parse Parsed HTML into a doc.

3.// 解析body片段

    @Test
    public void test2() {
        String html = "<div><p>Lorem ipsum.</p>";
        Document doc = Jsoup.parseBodyFragment(html);
        System.out.println(doc);
        System.out.println(doc.text());
    }

结果:

<html>
 <head></head>
 <body>
  <div>
   <p>Lorem ipsum.</p>
  </div>
 </body>
</html>
Lorem ipsum.

4.// 解析一个url与用选择器选择元素(相当于查看源码)

    @Test
    public void test4() throws IOException {
        Document doc = Jsoup.connect("http://qiaoliqiang.cn:8080/").get();
        String title = doc.title();// 获取title
        System.out.println(title);
        System.out.println("---------------------\n"+doc.toString()+"---------------------\n");// 输出文档全部
        Elements links = doc.getElementsByTag("a");
        for (Element ele : links) {
            System.out.println(ele.toString());
        }
    }

Apache Tomcat/7.0.72
---------------------
<!doctype html>
<html lang="en">
 <head>
  <title>Apache Tomcat/7.0.72</title>
  <link href="favicon.ico" rel="icon" type="image/x-icon">
  <link href="favicon.ico" rel="shortcut icon" type="image/x-icon">
  <link href="tomcat.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div id="wrapper">
   <div id="navigation" class="curved container">
    <span id="nav-home"><a href="http://tomcat.apache.org/">Home</a></span>
    <span id="nav-hosts"><a href="/docs/">Documentation</a></span>
    <span id="nav-config"><a href="/docs/config/">Configuration</a></span>
    <span id="nav-examples"><a href="/examples/">Examples</a></span>
    <span id="nav-wiki"><a href="http://wiki.apache.org/tomcat/FrontPage">Wiki</a></span>
    <span id="nav-lists"><a href="http://tomcat.apache.org/lists.html">Mailing Lists</a></span>
    <span id="nav-help"><a href="http://tomcat.apache.org/findhelp.html">Find Help</a></span>
    <br class="separator">
   </div>
   <div id="asf-box">
    <h1>Apache Tomcat/7.0.72</h1>
   </div>
   <div id="upper" class="curved container">
    <div id="congrats" class="curved container">
     <h2>If you‘re seeing this, you‘ve successfully installed Tomcat. Congratulations!</h2>
    </div>
    <div id="notice">
     <img src="tomcat.png" alt="[tomcat logo]">
     <div id="tasks">
      <h3>Recommended Reading:</h3>
      <h4><a href="/docs/security-howto.html">Security Considerations HOW-TO</a></h4>
      <h4><a href="/docs/manager-howto.html">Manager Application HOW-TO</a></h4>
      <h4><a href="/docs/cluster-howto.html">Clustering/Session Replication HOW-TO</a></h4>
     </div>
    </div>
    <div id="actions">
     <div class="button">
      <a class="container shadow" href="/manager/status"><span>Server Status</span></a>
     </div>
     <div class="button">
      <a class="container shadow" href="/manager/html"><span>Manager App</span></a>
     </div>
     <div class="button">
      <a class="container shadow" href="/host-manager/html"><span>Host Manager</span></a>
     </div>
    </div>
    <!--
                <br class="separator" />
                -->
    <br class="separator">
   </div>
   <div id="middle" class="curved container">
    <h3>Developer Quick Start</h3>
    <div class="col25">
     <div class="container">
      <p><a href="/docs/setup.html">Tomcat Setup</a></p>
      <p><a href="/docs/appdev/">First Web Application</a></p>
     </div>
    </div>
    <div class="col25">
     <div class="container">
      <p><a href="/docs/realm-howto.html">Realms &amp; AAA</a></p>
      <p><a href="/docs/jndi-datasource-examples-howto.html">JDBC DataSources</a></p>
     </div>
    </div>
    <div class="col25">
     <div class="container">
      <p><a href="/examples/">Examples</a></p>
     </div>
    </div>
    <div class="col25">
     <div class="container">
      <p><a href="http://wiki.apache.org/tomcat/Specifications">Servlet Specifications</a></p>
      <p><a href="http://wiki.apache.org/tomcat/TomcatVersions">Tomcat Versions</a></p>
     </div>
    </div>
    <br class="separator">
   </div>
   <div id="lower">
    <div id="low-manage" class="">
     <div class="curved container">
      <h3>Managing Tomcat</h3>
      <p>For security, access to the <a href="/manager/html">manager webapp</a> is restricted. Users are defined in:</p>
      <pre>$CATALINA_HOME/conf/tomcat-users.xml</pre>
      <p>In Tomcat 7.0 access to the manager application is split between different users. &nbsp; <a href="/docs/manager-howto.html">Read more...</a></p>
      <br>
      <h4><a href="/docs/RELEASE-NOTES.txt">Release Notes</a></h4>
      <h4><a href="/docs/changelog.html">Changelog</a></h4>
      <h4><a href="http://tomcat.apache.org/migration.html">Migration Guide</a></h4>
      <h4><a href="http://tomcat.apache.org/security.html">Security Notices</a></h4>
     </div>
    </div>
    <div id="low-docs" class="">
     <div class="curved container">
      <h3>Documentation</h3>
      <h4><a href="/docs/">Tomcat 7.0 Documentation</a></h4>
      <h4><a href="/docs/config/">Tomcat 7.0 Configuration</a></h4>
      <h4><a href="http://wiki.apache.org/tomcat/FrontPage">Tomcat Wiki</a></h4>
      <p>Find additional important configuration information in:</p>
      <pre>$CATALINA_HOME/RUNNING.txt</pre>
      <p>Developers may be interested in:</p>
      <ul>
       <li><a href="http://tomcat.apache.org/bugreport.html">Tomcat 7.0 Bug Database</a></li>
       <li><a href="/docs/api/index.html">Tomcat 7.0 JavaDocs</a></li>
       <li><a href="http://svn.apache.org/repos/asf/tomcat/tc7.0.x/">Tomcat 7.0 SVN Repository</a></li>
      </ul>
     </div>
    </div>
    <div id="low-help" class="">
     <div class="curved container">
      <h3>Getting Help</h3>
      <h4><a href="http://tomcat.apache.org/faq/">FAQ</a> and <a href="http://tomcat.apache.org/lists.html">Mailing Lists</a></h4>
      <p>The following mailing lists are available:</p>
      <ul>
       <li id="list-announce"><strong><a href="http://tomcat.apache.org/lists.html#tomcat-announce">tomcat-announce</a><br> Important announcements, releases, security vulnerability notifications. (Low volume).</strong> </li>
       <li><a href="http://tomcat.apache.org/lists.html#tomcat-users">tomcat-users</a><br> User support and discussion </li>
       <li><a href="http://tomcat.apache.org/lists.html#taglibs-user">taglibs-user</a><br> User support and discussion for <a href="http://tomcat.apache.org/taglibs/">Apache Taglibs</a> </li>
       <li><a href="http://tomcat.apache.org/lists.html#tomcat-dev">tomcat-dev</a><br> Development mailing list, including commit messages </li>
      </ul>
     </div>
    </div>
    <br class="separator">
   </div>
   <div id="footer" class="curved container">
    <div class="col20">
     <div class="container">
      <h4>Other Downloads</h4>
      <ul>
       <li><a href="http://tomcat.apache.org/download-connectors.cgi">Tomcat Connectors</a></li>
       <li><a href="http://tomcat.apache.org/download-native.cgi">Tomcat Native</a></li>
       <li><a href="http://tomcat.apache.org/taglibs/">Taglibs</a></li>
       <li><a href="/docs/deployer-howto.html">Deployer</a></li>
      </ul>
     </div>
    </div>
    <div class="col20">
     <div class="container">
      <h4>Other Documentation</h4>
      <ul>
       <li><a href="http://tomcat.apache.org/connectors-doc/">Tomcat Connectors</a></li>
       <li><a href="http://tomcat.apache.org/connectors-doc/">mod_jk Documentation</a></li>
       <li><a href="http://tomcat.apache.org/native-doc/">Tomcat Native</a></li>
       <li><a href="/docs/deployer-howto.html">Deployer</a></li>
      </ul>
     </div>
    </div>
    <div class="col20">
     <div class="container">
      <h4>Get Involved</h4>
      <ul>
       <li><a href="http://tomcat.apache.org/getinvolved.html">Overview</a></li>
       <li><a href="http://tomcat.apache.org/svn.html">SVN Repositories</a></li>
       <li><a href="http://tomcat.apache.org/lists.html">Mailing Lists</a></li>
       <li><a href="http://wiki.apache.org/tomcat/FrontPage">Wiki</a></li>
      </ul>
     </div>
    </div>
    <div class="col20">
     <div class="container">
      <h4>Miscellaneous</h4>
      <ul>
       <li><a href="http://tomcat.apache.org/contact.html">Contact</a></li>
       <li><a href="http://tomcat.apache.org/legal.html">Legal</a></li>
       <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li>
       <li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li>
      </ul>
     </div>
    </div>
    <div class="col20">
     <div class="container">
      <h4>Apache Software Foundation</h4>
      <ul>
       <li><a href="http://tomcat.apache.org/whoweare.html">Who We Are</a></li>
       <li><a href="http://tomcat.apache.org/heritage.html">Heritage</a></li>
       <li><a href="http://www.apache.org">Apache Home</a></li>
       <li><a href="http://tomcat.apache.org/resources.html">Resources</a></li>
      </ul>
     </div>
    </div>
    <br class="separator">
   </div>
   <p class="copyright">Copyright ©1999-2017 Apache Software Foundation. All Rights Reserved</p>
  </div>  
 </body>
</html>---------------------

<a href="http://tomcat.apache.org/">Home</a>
<a href="/docs/">Documentation</a>
<a href="/docs/config/">Configuration</a>
<a href="/examples/">Examples</a>
<a href="http://wiki.apache.org/tomcat/FrontPage">Wiki</a>
<a href="http://tomcat.apache.org/lists.html">Mailing Lists</a>
<a href="http://tomcat.apache.org/findhelp.html">Find Help</a>
<a href="/docs/security-howto.html">Security Considerations HOW-TO</a>
<a href="/docs/manager-howto.html">Manager Application HOW-TO</a>
<a href="/docs/cluster-howto.html">Clustering/Session Replication HOW-TO</a>
<a class="container shadow" href="/manager/status"><span>Server Status</span></a>
<a class="container shadow" href="/manager/html"><span>Manager App</span></a>
<a class="container shadow" href="/host-manager/html"><span>Host Manager</span></a>
<a href="/docs/setup.html">Tomcat Setup</a>
<a href="/docs/appdev/">First Web Application</a>
<a href="/docs/realm-howto.html">Realms &amp; AAA</a>
<a href="/docs/jndi-datasource-examples-howto.html">JDBC DataSources</a>
<a href="/examples/">Examples</a>
<a href="http://wiki.apache.org/tomcat/Specifications">Servlet Specifications</a>
<a href="http://wiki.apache.org/tomcat/TomcatVersions">Tomcat Versions</a>
<a href="/manager/html">manager webapp</a>
<a href="/docs/manager-howto.html">Read more...</a>
<a href="/docs/RELEASE-NOTES.txt">Release Notes</a>
<a href="/docs/changelog.html">Changelog</a>
<a href="http://tomcat.apache.org/migration.html">Migration Guide</a>
<a href="http://tomcat.apache.org/security.html">Security Notices</a>
<a href="/docs/">Tomcat 7.0 Documentation</a>
<a href="/docs/config/">Tomcat 7.0 Configuration</a>
<a href="http://wiki.apache.org/tomcat/FrontPage">Tomcat Wiki</a>
<a href="http://tomcat.apache.org/bugreport.html">Tomcat 7.0 Bug Database</a>
<a href="/docs/api/index.html">Tomcat 7.0 JavaDocs</a>
<a href="http://svn.apache.org/repos/asf/tomcat/tc7.0.x/">Tomcat 7.0 SVN Repository</a>
<a href="http://tomcat.apache.org/faq/">FAQ</a>
<a href="http://tomcat.apache.org/lists.html">Mailing Lists</a>
<a href="http://tomcat.apache.org/lists.html#tomcat-announce">tomcat-announce</a>
<a href="http://tomcat.apache.org/lists.html#tomcat-users">tomcat-users</a>
<a href="http://tomcat.apache.org/lists.html#taglibs-user">taglibs-user</a>
<a href="http://tomcat.apache.org/taglibs/">Apache Taglibs</a>
<a href="http://tomcat.apache.org/lists.html#tomcat-dev">tomcat-dev</a>
<a href="http://tomcat.apache.org/download-connectors.cgi">Tomcat Connectors</a>
<a href="http://tomcat.apache.org/download-native.cgi">Tomcat Native</a>
<a href="http://tomcat.apache.org/taglibs/">Taglibs</a>
<a href="/docs/deployer-howto.html">Deployer</a>
<a href="http://tomcat.apache.org/connectors-doc/">Tomcat Connectors</a>
<a href="http://tomcat.apache.org/connectors-doc/">mod_jk Documentation</a>
<a href="http://tomcat.apache.org/native-doc/">Tomcat Native</a>
<a href="/docs/deployer-howto.html">Deployer</a>
<a href="http://tomcat.apache.org/getinvolved.html">Overview</a>
<a href="http://tomcat.apache.org/svn.html">SVN Repositories</a>
<a href="http://tomcat.apache.org/lists.html">Mailing Lists</a>
<a href="http://wiki.apache.org/tomcat/FrontPage">Wiki</a>
<a href="http://tomcat.apache.org/contact.html">Contact</a>
<a href="http://tomcat.apache.org/legal.html">Legal</a>
<a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a>
<a href="http://www.apache.org/foundation/thanks.html">Thanks</a>
<a href="http://tomcat.apache.org/whoweare.html">Who We Are</a>
<a href="http://tomcat.apache.org/heritage.html">Heritage</a>
<a href="http://www.apache.org">Apache Home</a>
<a href="http://tomcat.apache.org/resources.html">Resources</a>

5.// 解析一个url与用选择器选择元素(相当于查看源码)

    @Test
    public void test5() throws IOException {
        Document doc = Jsoup.connect("http://qiaoliqiang.cn:8080/").get();
//        System.out.println(doc.text());// 输出doc.text()
        String title = doc.title();// 获取title
        System.out.println(title);
//        System.out.println(doc.toString());// 输出文档全部
        Elements links = doc.select("img"); // 带有img标签
        for (Element ele : links) {
            System.out.println(ele.toString());
        }
    }

结果:

Apache Tomcat/7.0.72
<img src="tomcat.png" alt="[tomcat logo]">

Apache Tomcat/7.0.72 Home Documentation Configuration Examples Wiki Mailing Lists Find Help Apache Tomcat/7.0.72 If you‘re seeing this, you‘ve successfully installed Tomcat. Congratulations! Recommended Reading: Security Considerations HOW-TO Manager Application HOW-TO Clustering/Session Replication HOW-TO Server Status Manager App Host Manager Developer Quick Start Tomcat Setup First Web Application Realms & AAA JDBC DataSources Examples Servlet Specifications Tomcat Versions Managing Tomcat For security, access to the manager webapp is restricted. Users are defined in: $CATALINA_HOME/conf/tomcat-users.xml In Tomcat 7.0 access to the manager application is split between different users.   Read more... Release Notes Changelog Migration Guide Security Notices Documentation Tomcat 7.0 Documentation Tomcat 7.0 Configuration Tomcat Wiki Find additional important configuration information in: $CATALINA_HOME/RUNNING.txt Developers may be interested in: Tomcat 7.0 Bug Database Tomcat 7.0 JavaDocs Tomcat 7.0 SVN Repository Getting Help FAQ and Mailing Lists The following mailing lists are available: tomcat-announce Important announcements, releases, security vulnerability notifications. (Low volume). tomcat-users User support and discussion taglibs-user User support and discussion for Apache Taglibs tomcat-dev Development mailing list, including commit messages Other Downloads Tomcat Connectors Tomcat Native Taglibs Deployer Other Documentation Tomcat Connectors mod_jk Documentation Tomcat Native Deployer Get Involved Overview SVN Repositories Mailing Lists Wiki Miscellaneous Contact Legal Sponsorship Thanks Apache Software Foundation Who We Are Heritage Apache Home Resources Copyright ©1999-2017 Apache Software Foundation. All Rights Reserved
Apache Tomcat/7.0.72
<!doctype html>
<html lang="en">
 <head>
  <title>Apache Tomcat/7.0.72</title>
  <link href="favicon.ico" rel="icon" type="image/x-icon">
  <link href="favicon.ico" rel="shortcut icon" type="image/x-icon">
  <link href="tomcat.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div id="wrapper">
   <div id="navigation" class="curved container">
    <span id="nav-home"><a href="http://tomcat.apache.org/">Home</a></span>
    <span id="nav-hosts"><a href="/docs/">Documentation</a></span>
    <span id="nav-config"><a href="/docs/config/">Configuration</a></span>
    <span id="nav-examples"><a href="/examples/">Examples</a></span>
    <span id="nav-wiki"><a href="http://wiki.apache.org/tomcat/FrontPage">Wiki</a></span>
    <span id="nav-lists"><a href="http://tomcat.apache.org/lists.html">Mailing Lists</a></span>
    <span id="nav-help"><a href="http://tomcat.apache.org/findhelp.html">Find Help</a></span>
    <br class="separator">
   </div>
   <div id="asf-box">
    <h1>Apache Tomcat/7.0.72</h1>
   </div>
   <div id="upper" class="curved container">
    <div id="congrats" class="curved container">
     <h2>If you‘re seeing this, you‘ve successfully installed Tomcat. Congratulations!</h2>
    </div>
    <div id="notice">
     <img src="tomcat.png" alt="[tomcat logo]">
     <div id="tasks">
      <h3>Recommended Reading:</h3>
      <h4><a href="/docs/security-howto.html">Security Considerations HOW-TO</a></h4>
      <h4><a href="/docs/manager-howto.html">Manager Application HOW-TO</a></h4>
      <h4><a href="/docs/cluster-howto.html">Clustering/Session Replication HOW-TO</a></h4>
     </div>
    </div>
    <div id="actions">
     <div class="button">
      <a class="container shadow" href="/manager/status"><span>Server Status</span></a>
     </div>
     <div class="button">
      <a class="container shadow" href="/manager/html"><span>Manager App</span></a>
     </div>
     <div class="button">
      <a class="container shadow" href="/host-manager/html"><span>Host Manager</span></a>
     </div>
    </div>
    <!--
                <br class="separator" />
                -->
    <br class="separator">
   </div>
   <div id="middle" class="curved container">
    <h3>Developer Quick Start</h3>
    <div class="col25">
     <div class="container">
      <p><a href="/docs/setup.html">Tomcat Setup</a></p>
      <p><a href="/docs/appdev/">First Web Application</a></p>
     </div>
    </div>
    <div class="col25">
     <div class="container">
      <p><a href="/docs/realm-howto.html">Realms &amp; AAA</a></p>
      <p><a href="/docs/jndi-datasource-examples-howto.html">JDBC DataSources</a></p>
     </div>
    </div>
    <div class="col25">
     <div class="container">
      <p><a href="/examples/">Examples</a></p>
     </div>
    </div>
    <div class="col25">
     <div class="container">
      <p><a href="http://wiki.apache.org/tomcat/Specifications">Servlet Specifications</a></p>
      <p><a href="http://wiki.apache.org/tomcat/TomcatVersions">Tomcat Versions</a></p>
     </div>
    </div>
    <br class="separator">
   </div>
   <div id="lower">
    <div id="low-manage" class="">
     <div class="curved container">
      <h3>Managing Tomcat</h3>
      <p>For security, access to the <a href="/manager/html">manager webapp</a> is restricted. Users are defined in:</p>
      <pre>$CATALINA_HOME/conf/tomcat-users.xml</pre>
      <p>In Tomcat 7.0 access to the manager application is split between different users. &nbsp; <a href="/docs/manager-howto.html">Read more...</a></p>
      <br>
      <h4><a href="/docs/RELEASE-NOTES.txt">Release Notes</a></h4>
      <h4><a href="/docs/changelog.html">Changelog</a></h4>
      <h4><a href="http://tomcat.apache.org/migration.html">Migration Guide</a></h4>
      <h4><a href="http://tomcat.apache.org/security.html">Security Notices</a></h4>
     </div>
    </div>
    <div id="low-docs" class="">
     <div class="curved container">
      <h3>Documentation</h3>
      <h4><a href="/docs/">Tomcat 7.0 Documentation</a></h4>
      <h4><a href="/docs/config/">Tomcat 7.0 Configuration</a></h4>
      <h4><a href="http://wiki.apache.org/tomcat/FrontPage">Tomcat Wiki</a></h4>
      <p>Find additional important configuration information in:</p>
      <pre>$CATALINA_HOME/RUNNING.txt</pre>
      <p>Developers may be interested in:</p>
      <ul>
       <li><a href="http://tomcat.apache.org/bugreport.html">Tomcat 7.0 Bug Database</a></li>
       <li><a href="/docs/api/index.html">Tomcat 7.0 JavaDocs</a></li>
       <li><a href="http://svn.apache.org/repos/asf/tomcat/tc7.0.x/">Tomcat 7.0 SVN Repository</a></li>
      </ul>
     </div>
    </div>
    <div id="low-help" class="">
     <div class="curved container">
      <h3>Getting Help</h3>
      <h4><a href="http://tomcat.apache.org/faq/">FAQ</a> and <a href="http://tomcat.apache.org/lists.html">Mailing Lists</a></h4>
      <p>The following mailing lists are available:</p>
      <ul>
       <li id="list-announce"><strong><a href="http://tomcat.apache.org/lists.html#tomcat-announce">tomcat-announce</a><br> Important announcements, releases, security vulnerability notifications. (Low volume).</strong> </li>
       <li><a href="http://tomcat.apache.org/lists.html#tomcat-users">tomcat-users</a><br> User support and discussion </li>
       <li><a href="http://tomcat.apache.org/lists.html#taglibs-user">taglibs-user</a><br> User support and discussion for <a href="http://tomcat.apache.org/taglibs/">Apache Taglibs</a> </li>
       <li><a href="http://tomcat.apache.org/lists.html#tomcat-dev">tomcat-dev</a><br> Development mailing list, including commit messages </li>
      </ul>
     </div>
    </div>
    <br class="separator">
   </div>
   <div id="footer" class="curved container">
    <div class="col20">
     <div class="container">
      <h4>Other Downloads</h4>
      <ul>
       <li><a href="http://tomcat.apache.org/download-connectors.cgi">Tomcat Connectors</a></li>
       <li><a href="http://tomcat.apache.org/download-native.cgi">Tomcat Native</a></li>
       <li><a href="http://tomcat.apache.org/taglibs/">Taglibs</a></li>
       <li><a href="/docs/deployer-howto.html">Deployer</a></li>
      </ul>
     </div>
    </div>
    <div class="col20">
     <div class="container">
      <h4>Other Documentation</h4>
      <ul>
       <li><a href="http://tomcat.apache.org/connectors-doc/">Tomcat Connectors</a></li>
       <li><a href="http://tomcat.apache.org/connectors-doc/">mod_jk Documentation</a></li>
       <li><a href="http://tomcat.apache.org/native-doc/">Tomcat Native</a></li>
       <li><a href="/docs/deployer-howto.html">Deployer</a></li>
      </ul>
     </div>
    </div>
    <div class="col20">
     <div class="container">
      <h4>Get Involved</h4>
      <ul>
       <li><a href="http://tomcat.apache.org/getinvolved.html">Overview</a></li>
       <li><a href="http://tomcat.apache.org/svn.html">SVN Repositories</a></li>
       <li><a href="http://tomcat.apache.org/lists.html">Mailing Lists</a></li>
       <li><a href="http://wiki.apache.org/tomcat/FrontPage">Wiki</a></li>
      </ul>
     </div>
    </div>
    <div class="col20">
     <div class="container">
      <h4>Miscellaneous</h4>
      <ul>
       <li><a href="http://tomcat.apache.org/contact.html">Contact</a></li>
       <li><a href="http://tomcat.apache.org/legal.html">Legal</a></li>
       <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li>
       <li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li>
      </ul>
     </div>
    </div>
    <div class="col20">
     <div class="container">
      <h4>Apache Software Foundation</h4>
      <ul>
       <li><a href="http://tomcat.apache.org/whoweare.html">Who We Are</a></li>
       <li><a href="http://tomcat.apache.org/heritage.html">Heritage</a></li>
       <li><a href="http://www.apache.org">Apache Home</a></li>
       <li><a href="http://tomcat.apache.org/resources.html">Resources</a></li>
      </ul>
     </div>
    </div>
    <br class="separator">
   </div>
   <p class="copyright">Copyright ©1999-2017 Apache Software Foundation. All Rights Reserved</p>
  </div>   
 </body>
</html>
<a href="http://tomcat.apache.org/">Home</a>
<a href="/docs/">Documentation</a>
<a href="/docs/config/">Configuration</a>
<a href="/examples/">Examples</a>
<a href="http://wiki.apache.org/tomcat/FrontPage">Wiki</a>
<a href="http://tomcat.apache.org/lists.html">Mailing Lists</a>
<a href="http://tomcat.apache.org/findhelp.html">Find Help</a>
<a href="/docs/security-howto.html">Security Considerations HOW-TO</a>
<a href="/docs/manager-howto.html">Manager Application HOW-TO</a>
<a href="/docs/cluster-howto.html">Clustering/Session Replication HOW-TO</a>
<a class="container shadow" href="/manager/status"><span>Server Status</span></a>
<a class="container shadow" href="/manager/html"><span>Manager App</span></a>
<a class="container shadow" href="/host-manager/html"><span>Host Manager</span></a>
<a href="/docs/setup.html">Tomcat Setup</a>
<a href="/docs/appdev/">First Web Application</a>
<a href="/docs/realm-howto.html">Realms &amp; AAA</a>
<a href="/docs/jndi-datasource-examples-howto.html">JDBC DataSources</a>
<a href="/examples/">Examples</a>
<a href="http://wiki.apache.org/tomcat/Specifications">Servlet Specifications</a>
<a href="http://wiki.apache.org/tomcat/TomcatVersions">Tomcat Versions</a>
<a href="/manager/html">manager webapp</a>
<a href="/docs/manager-howto.html">Read more...</a>
<a href="/docs/RELEASE-NOTES.txt">Release Notes</a>
<a href="/docs/changelog.html">Changelog</a>
<a href="http://tomcat.apache.org/migration.html">Migration Guide</a>
<a href="http://tomcat.apache.org/security.html">Security Notices</a>
<a href="/docs/">Tomcat 7.0 Documentation</a>
<a href="/docs/config/">Tomcat 7.0 Configuration</a>
<a href="http://wiki.apache.org/tomcat/FrontPage">Tomcat Wiki</a>
<a href="http://tomcat.apache.org/bugreport.html">Tomcat 7.0 Bug Database</a>
<a href="/docs/api/index.html">Tomcat 7.0 JavaDocs</a>
<a href="http://svn.apache.org/repos/asf/tomcat/tc7.0.x/">Tomcat 7.0 SVN Repository</a>
<a href="http://tomcat.apache.org/faq/">FAQ</a>
<a href="http://tomcat.apache.org/lists.html">Mailing Lists</a>
<a href="http://tomcat.apache.org/lists.html#tomcat-announce">tomcat-announce</a>
<a href="http://tomcat.apache.org/lists.html#tomcat-users">tomcat-users</a>
<a href="http://tomcat.apache.org/lists.html#taglibs-user">taglibs-user</a>
<a href="http://tomcat.apache.org/taglibs/">Apache Taglibs</a>
<a href="http://tomcat.apache.org/lists.html#tomcat-dev">tomcat-dev</a>
<a href="http://tomcat.apache.org/download-connectors.cgi">Tomcat Connectors</a>
<a href="http://tomcat.apache.org/download-native.cgi">Tomcat Native</a>
<a href="http://tomcat.apache.org/taglibs/">Taglibs</a>
<a href="/docs/deployer-howto.html">Deployer</a>
<a href="http://tomcat.apache.org/connectors-doc/">Tomcat Connectors</a>
<a href="http://tomcat.apache.org/connectors-doc/">mod_jk Documentation</a>
<a href="http://tomcat.apache.org/native-doc/">Tomcat Native</a>
<a href="/docs/deployer-howto.html">Deployer</a>
<a href="http://tomcat.apache.org/getinvolved.html">Overview</a>
<a href="http://tomcat.apache.org/svn.html">SVN Repositories</a>
<a href="http://tomcat.apache.org/lists.html">Mailing Lists</a>
<a href="http://wiki.apache.org/tomcat/FrontPage">Wiki</a>
<a href="http://tomcat.apache.org/contact.html">Contact</a>
<a href="http://tomcat.apache.org/legal.html">Legal</a>
<a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a>
<a href="http://www.apache.org/foundation/thanks.html">Thanks</a>
<a href="http://tomcat.apache.org/whoweare.html">Who We Are</a>
<a href="http://tomcat.apache.org/heritage.html">Heritage</a>
<a href="http://www.apache.org">Apache Home</a>
<a href="http://tomcat.apache.org/resources.html">Resources</a>

时间: 2024-08-10 19:19:20

Jsoup解析Html标签(Java后台解析)的相关文章

Java后台解析android端发送的JSON字符串

在设备通讯中,往往会用到数据交互.我们这里用的是通过HTTP协议发送JSON数据,android客户端把数据进行打包,发送到后台服务器,后台解析出来. //android客户端拼装JSON字符串 //如下的拼装结果为: {"data":[{"id":"12345","name":"张三"},{"id":"54321","name":"李四

java 后台解析excel上传数据 工具类

后台调用: MultipartFile file: List<String[]> excelDate package com.holike.crm.partner.sys; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; import org.apache.poi.h

Java后台 解析JSON的几个方法

1.对象转JSON对象. public static void main(String[] args) { Domain demo = new Domain( "在线JSON校验格式化工具 -SOJSON在线工具(sojson.com)", "http://www.sojson.com/", "提供json在线格式化,json在线格式化工具,json 格式化输出,json格式化 空串,json 格式化插件,json字符串格式化,json视图,json 在线

jsoup: Java HTML 解析器

jsoup 是一款Java 的HTML解析器,可直接解析某个URL地址.HTML文本内容. 请参考:jsoup.org 例如: beanshell 抓取CSDN极客头条内容  soup.bsh // package org.jsoup.examples; import org.jsoup.Jsoup; import org.jsoup.helper.Validate; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element;

使用 jsoup 对 HTML 文档进行解析和操作

jsoup 简介 Java 程序在解析 HTML 文档时,相信大家都接触过 htmlparser 这个开源项目,我曾经在 IBM DW 上发表过两篇关于 htmlparser 的文章,分别是:从 HTML 中攫取你所需的信息和 扩展 HTMLParser 对自定义标签的处理能力.但现在我已经不再使用 htmlparser 了,原因是 htmlparser 很少更新,但最重要的是有了 jsoup . jsoup 是一款 Java 的 HTML 解析器,可直接解析某个 URL 地址.HTML 文本内

Java数据解析---PULL

安卓和JAVA解析xml文件的三种方式: 1.PULL解析 2.SAX解析 3.DOM解析 三者各有所长,依情况选择解析方式 1.PULL和SAX均采用流式解析,意味着只能从头读到底,无法像DOM解析一样随机访问xml文件中的任意一个节点 2.PULL和SAX占用更少的内存解析,更适用于安卓上的解析xml文件 3.DOM解析时将文件全部解析完,最后让用户任意取特定的信息 ---------------------------------------------------------------

JSP页面中使用JSTL标签出现无法解析问题解决办法

今天建立一个JavaWeb工程测试JNDI数据源连接,在jsp页面中引入了JSLT标签库,代码如下: 1<%@ page language="java"import="java.util.*"pageEncoding="UTF-8"%> 2<%@ taglib uri="http://java.sun.com/jsp/jstl/core"prefix="c"%> 3<%@ ta

Java泛型解析(03):虚拟机执行泛型代码

Java泛型解析(03):虚拟机执行泛型代码 Java虚拟机是不存在泛型类型对象的,所有的对象都属于普通类,甚至在泛型实现的早起版本中,可以将使用泛型的程序编译为在1.0虚拟机上能够运行的class文件,这个向后兼容性后期被抛弃了,所以后来如果用Sun公司的编译器编译的泛型代码,是不能运行在Java5.0之前的虚拟机的,这样就导致了一些实际生产的问题,如一些遗留代码如何跟新的系统进行衔接,要弄明白这个问题,需要先了解一下虚拟机是怎么执行泛型代码的. 虚拟机的一种机制:擦除类型参数,并将其替换成特

Java数据解析---SAX

一.Sax解析 是从头到尾逐行逐个元素读取内容,修改较为不便,但适用于只读的大文档. Sax采用事件驱动的方式解析文档.简单点说,如同在电影院看电影一样,从头到尾看一遍就完了,不能回退(Dom可来来回回读取) 在看电影的过程中,每遇到一个情节,一段泪水,一次擦肩,你都会调动大脑和神经去接收或处理这些信息 同样,在Sax的解析过程中,读取到文档开头.结尾,元素的开头和结尾都会触发一些回调方法,你可以在这些回调方法中进行相应事件处理 这四个方法是:startDocument() . endDocum