Note that there are some explanatory texts on larger screens.

plurals
  1. POJava: download web content from Google https
    text
    copied!<p>I am trying to download the web content from Google https as in the link below. </p> <p><a href="https://www.google.com/webhp?hl=en&amp;tab=ww#hl=en&amp;tbs=dfn:1&amp;sa=X&amp;ei=obxCUKm7Ic3GqAGvoYGIBQ&amp;ved=0CDAQBSgA&amp;q=pronunciation&amp;spell=1&amp;bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&amp;fp=c5bfe0fbd78a3271&amp;biw=1024&amp;bih=759" rel="nofollow">link to download</a></p> <p>With the code below, I first disable the validation of certificates for testing purposes and trust all certificates, and then download the web as regular http, but for some reason, it is not successful:</p> <pre><code>public static void downloadWeb() { // Create a new trust manager that trust all certificates TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType) { } public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType) { } } }; // Activate the new trust manager try { SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection .setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch (Exception e) {} //begin download as regular http try { String wordAddress = "https://www.google.com/webhp?hl=en&amp;tab=ww#hl=en&amp;tbs=dfn:1&amp;sa=X&amp;ei=obxCUKm7Ic3GqAGvoYGIBQ&amp;ved=0CDAQBSgA&amp;q=pronunciation&amp;spell=1&amp;bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&amp;fp=c5bfe0fbd78a3271&amp;biw=1024&amp;bih=759"; URLConnection yc = new URL(wordAddress).openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader( yc.getInputStream())); String inputLine = ""; while ((inputLine = in.readLine()) != null) { System.out.println(wordAddress); } } catch (IOException e) {} } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload