title: Alternative of Jsoup.parse() method
body: <p>I use <code>Jsoup.parse()</code> to parse <a href="http://api.3botinka.com/api/synchronize" rel="nofollow">this data</a>. Everything works good but takes to much time. </p>
  
  <p>For example this data takes 20 sec. for parsing. Are there other solutions for my needs?</p>
  
  <p>Code:</p>
  
  <pre><code>rezult = Jsoup.parse(res.parse().outerHtml(), "UTF-8").text();
  </code></pre>
  
  <p>Where <code>res</code> it's text from <a href="http://api.3botinka.com/api/synchronize" rel="nofollow">link</a>.</p>
  
  <p><strong>=========== UPDATE =============</strong> </p>
  
  <p>I separate this variable from <code>Jsoup.parse()</code> and understood that it is the source of problem. It takes 20 seconds, not <code>Jsoup.parse()</code>.</p>
  
  <pre><code>String tmp = res.parse().outerHtml();
  </code></pre>
  
  <p>And this one takes only 1 sec.:</p>
  
  <pre><code>rezult = Jsoup.parse(tmp, "UTF-8").text();
  </code></pre>
  
  <p>I use this code to get data from this link. I use <code>Jsoup.parse()</code> because without it I got something like this:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;&lt;/head&gt;
      &lt;body&gt;
      {&amp;quot;success&amp;quot;:true,&amp;quot;currentUser&amp;quot;:43743,&amp;quot;careTypes&amp;quot;:[{&amp;quot;id&amp;quot;:1,&amp;quot;name&amp;quot;:&amp;quot;\u0421\u0442\u0438\u0440\u043a\u0430&amp;quot;,&amp;quot;description&amp;quot;:&amp;quot;\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0442\u0438\u0440\u043a\u0438 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0437\u0434\u0435\u0441\u044c, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b \u0432\u044b\u0431\u0435\u0440\u0435\u0442\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c\u044b\u0439 \u0440\u0435\u0436\u0438\u043c.&amp;quot;},{&amp;quot;id&amp;quot;:2,&amp;quot;name&amp;quot;:&amp;quot;\u041e\u0442\u0431\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435&amp;quot;,&amp;quot;description&amp;quot;:&amp;quot;\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0442\u0431\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0437\u0434\u0435\u0441\u044c, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b \u0432\u044b\u0431\u0435\u0440\u0435\u0442\u0435 
  </code></pre>
  
  <p>instead this:</p>
  
  <pre><code>{"success":true,"currentUser":43743,"careTypes":[{"id":1,"name":"\u0421\u0442\u0438\u0440\u043a\u0430","description":"\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0442\u0438\u0440\u043a\u0438 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0437\u0434\u0435\u0441\u044c, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b \u0432\u044b\u0431\u0435\u0440\u0435\u0442\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c\u044b\u0439 \u0440\u0435\u0436\u0438\u043c."},{"id":2,"name":"\u041e\u0442\u0431\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435","description":"\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0442\u0431\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0437\u0434\u0435\u0441\u044c, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b \u0432\u044b\u0431\u0435\u0440\u0435\u0442\u0435 
  </code></pre>
  
  <p>But now the main problem is to change <code>res.parse()</code> method to something other with less execution time.</p>
  
  <p><strong>=========== UPDATE 2 =============</strong></p>
  
  <pre><code> long t2 = System.currentTimeMillis();
          try {
              Connection connection = Jsoup.connect(url)
                      .method(Connection.Method.POST)
                      .cookies(cookies)
                      .timeout(30000)
                      .ignoreContentType(true);
              if (data != null) {
                  connection.data(data);
              }
  
              res = connection.execute();
  
              Logger.d(System.currentTimeMillis() - t2 + " = connection.execute");
  
              long t6 = System.currentTimeMillis();
              String tmp = res.parse().outerHtml();
              Logger.d(System.currentTimeMillis() - t6 + " = res.parse().outerHtml()");
  
              long t4 = System.currentTimeMillis();
              rezult = Jsoup.parse(tmp, "UTF-8").text();
              Logger.d(System.currentTimeMillis() - t4 + " = Jsoup.parse");
  </code></pre>
  
  <p>And what I got in Logcat:</p>
  
  <pre><code>1588 = connection.execute
  16150 = res.parse().outerHtml()
  1466 = Jsoup.parse
  </code></pre>