Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8575823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:46:56+00:00 2026-06-11T19:46:56+00:00

I’m trying to fetch a page using Android’s DefaultHTTPClient and parse it using Jsoup.

  • 0

I’m trying to fetch a page using Android’s DefaultHTTPClient and parse it using Jsoup. I’m getting a really weird response in which all the HTML within the <body> and </body> tags are encoded into something.

<html>
  <head></head>
  <body>
       ��������������Y�#I�&amp;�\�+��*;����/U���53�*��U�=�D�I:I� ����X�����΃��=H��2�`Ѓ  ��o��nͽ�C瘹;�l2Y�I_l�����;f��W�k��o2.����?�r&gt;��œ�qYξ&lt;&lt;&lt;;;�g*��ѡl���9&gt;s@I��`R��V �c�������Ɂ��e�����,&gt; }���A�����W�?��&quot;.��ˡhޖ�Qy1�oL�_�W�h?9�E?Ofe��KO�Q��(�Av�N�h@��G�qvV�_G��W�g�'q�2�N��L�?�&quot;鳷�x�o�����$9�}/;'#ȸ Q��&amp;�2�\�a��aǔ�L�I�ԯ�=���TPFE� ���:�,�H�N�'QQԯ&lt;&gt;�i}�x��'$�'O ��qy@J�h 2��ᓃ�CH��ʤO���0�LD)��p8�챺)
  </body>
</html>

Here’s my method that fetches the page.

  public String doGet(String strUrl, List<NameValuePair> lstParams) throws Exception {

          String strResponse = null;
          HttpGet htpGet = new HttpGet(strUrl);
          //htpGet.addHeader("Accept-Encoding", "gzip, deflate");
          htpGet.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1");
          DefaultHttpClient dhcClient = new DefaultHttpClient();
          PersistentCookieStore pscStore = new PersistentCookieStore(this.objContext);
          dhcClient.setCookieStore(pscStore);
          HttpResponse resResponse = dhcClient.execute(htpGet);
          strResponse = EntityUtils.toString(resResponse.getEntity());
          return strResponse;

  }

Why can this be happening?

If I fetch the page using Jsoup itself, the response is fine. I have to use Jsoup.connect("http://www.kat.ph/").get()

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:46:57+00:00Added an answer on June 11, 2026 at 7:46 pm

    It was due to the fact that the response was GZIPped. I wired up a custom response interceptor that uncompressed the response. This is it:

    class Decompressor implements HttpResponseInterceptor {
    
        /*
         * @see org.apache.http.HttpResponseInterceptor#process(org.apache.http.
         * HttpResponse, org.apache.http.protocol.HttpContext)
         */
        public void process(HttpResponse hreResponse, HttpContext hctContext)   throws HttpException, IOException {
    
            HttpEntity entity = hreResponse.getEntity();
    
            if (entity != null) {
    
                Header ceheader = entity.getContentEncoding();
    
                if (ceheader != null) {
    
                    HeaderElement[] codecs = ceheader.getElements();
    
                    for (int i = 0; i < codecs.length; i++) {
    
                        if (codecs[i].getName().equalsIgnoreCase("gzip")) {
    
                            hreResponse.setEntity(new HttpEntityWrapper(entity) {
    
                                @Override
                                public InputStream getContent() throws IOException, IllegalStateException {
    
                                    return new GZIPInputStream(wrappedEntity.getContent());
    
                                }
    
                                @Override
                                public long getContentLength() {
    
                                    return -1;
    
                                }
    
                            });
    
                            return;
    
                        }
    
                    }
    
                }
    
            }
    
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm trying to select an H1 element which is the second-child in its group
I have a text area in my form which accepts all possible characters from
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.