Two ways to http request give another results one by JAVA code and second by copy element from website

51 Views Asked by At

Two ways to http request give another results one by JAVA code and second by copy element from website.

I am try to match them to same result! When I use Java Code

    private static boolean isValid(URL url, HttpURLConnection connection) {

    BufferedReader reader;
    String line;
    StringBuffer responseContant = new StringBuffer();

    try {

        connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("GET");
        connection.setConnectTimeout(4000);
        connection.setReadTimeout(4000);

        int status = connection.getResponseCode();

        if (status > 299) {
            reader = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
            while ((line = reader.readLine()) != null)
                responseContant.append(line);
            reader.close();
        } else {
            reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            while ((line = reader.readLine()) != null)
                responseContant.append(line);
            reader.close();
            return true;
        }

    } catch (Exception e) {
        e.printStackTrace();

    }
    return false;
}

It give me another value instead use inspect> copy> copy element How it possible? and how to fix this issue?

Thanks guys!!

0

There are 0 best solutions below