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 8653381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:31:40+00:00 2026-06-12T14:31:40+00:00

I have a service that downloads HTML source code of certain website and then

  • 0

I have a service that downloads HTML source code of certain website and then compares it to the previously downloaded one from the same website, to see if any changes have occured.

The problem I had yesterday: I was connected to WiFi in public and my service started downloading the code, since it wasn’t showing that there’s no connection. But you first have to login when using public WiFi so it was redirected to their login page and my service downloaded the HTML code of a login page.

How can I surely get the source code of the site I want?

Here’s the source code (btw I turn source code into md5 for easier comparison but it’s not important):

public class DownloadHandler{

public String getMd5(String url){
    HttpClient client = new DefaultHttpClient();

    HttpGet request = new HttpGet(url);

    HttpResponse response = null;

    try {
        response = client.execute(request);
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    InputStream in = null;
    try {
        in = response.getEntity().getContent();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    BufferedReader reader = new BufferedReader(new InputStreamReader(in));

    StringBuilder str = new StringBuilder();
    String line = null;
    try {
        while ((line = reader.readLine()) != null) {
            str.append(line);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    try {
        in.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    String HTML = str.toString();

    try {
        String md5 = stringToMd5(html);
        return md5;
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
        return null;
    }

}

public String stringToMd5(String s) throws NoSuchAlgorithmException {
    MessageDigest md5 = MessageDigest.getInstance("MD5");stringa
    md5.update(s.getBytes(), 0, s.length());
    String md5String = new BigInteger(1, md5.digest()).toString(16);
    return md5String;
}

And the function to check connection:

boolean isNetworkAvailable() {
    ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetworkInfo = connectivityManager
            .getActiveNetworkInfo();
    return activeNetworkInfo != null;
}
  • 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-12T14:31:42+00:00Added an answer on June 12, 2026 at 2:31 pm

    you can disable redirects using

    HttpGet httpGet = new HttpGet("www.google.com");
    HttpParams params = httpGet.getParams();
    params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE);
    httpGet.setParams(params);
    

    but you should still check for http status code which should be 200

    HttpResponse httpResp = client.execute(response);
    int code = httpResp.getStatusLine().getStatusCode();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Service that downloads a file from the internet. What I want
I have an application that downloads information from a web service and caches it
I have a Service that downloads data from the Internet in AsyncTasks. It parses
I have a service which has a method that downloads an image from an
I have a desktop application that needs to upload/download images to/from service computer over
I have a service which periodically downloads some updates from a web site. Default
I have a singleton class that will initialize it's data from a web service
I have written a simple service that uploads & downloads XML files. I want
I have a service that i retrieve 7 URL's. Oncei retrieve the URLs from
I have some AsyncTask class that executing from service: public class DownloadTask extends AsyncTask<Void,

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.