Rectangle 27 0

I was facing the same issue with Jsoup, I was not able to connect and get the document for https urls but when I changed my JDK version from 1.7 to 1.8, the issue got resolved.

java - How to connect via HTTPS using Jsoup? - Stack Overflow

java android https web-scraping jsoup
Rectangle 27 0

This problem occurs not only using cookies, but also doing two simple connections using currentTempDocument = Jsoup.connect(url).get(); to read 2 different urls in the same activity: when I attempt to read the second url, only the 2nd attempt is ok. This problem disappears as suggested in the comment, i.e using

System.setProperty("http.keepAlive", "false");

or also as suggested in the question, i.e. using two nested try/catch blocks so that when the 1st attempt fails, the 2nd one goes ok

java - Problem with jsoup in android 2.2 - only connects on the second...

java android jsoup
Rectangle 27 0

It seems JSoup is trying to read cookies from a previous HttpConnection

On first try, no old connection, so the code works fine, but on second try, it may be trying to read cookies from the past connection, which is closed, or dereferenced.

I did not go as far as reading the Android 2.2 code, but probably the best way for you is to continue doing things the way you are doing right now.

Since it works fine on 2.3, as it should, I am tempted to say it's a mismatch between the way Android 2.2 handles cookies, and the way JSoup handles HttpConnection.

It seems like the problem is solved by adding: System.setProperty("http.keepAlive", "false"); at the beginning of the code. I'm accepting your answer, since it seems like it's the correct reason for the exception. Thanks!

java - Problem with jsoup in android 2.2 - only connects on the second...

java android jsoup
Rectangle 27 0

Try using a URL that specifies the scheme as well (http or https):

htmlFile = Jsoup.connect("http://www.amazon.in/Google-Nexus-D821-16GB-Black/dp/B00GC1J55C/ref=sr_1_1?s=electronics&ie=UTF8&qid=1421161258&sr=1-1&keywords=Google").get();
                         ^^^^^^^^
> url - URL to connect to. The protocol must be http or https.

Hi @Todd, I checked the API - jsoup.org/apidocs and didn't find any such method. Did I miss anything?

I copied that line directly from your code and just added "http://".

Oh! I didn't get that before. I added "http://" and now ran into a different exception. I'll edit the question. Please look at it. Thanks @Todd.

It's best to add a new question, or none of this will make sense in hindsight/context. Also, it's probably a good idea for you to try and fix it yourself first, that's how we learn.

java - Exception when connecting to a URL with jsoup - Stack Overflow

java android eclipse exception jsoup
Rectangle 27 0

I'm no expert in this field but I ran into a similar exception when trying to connect to a website over HTTPS using java.net APIs. The browser does a lot of work for you regarding SSL certificates when you visit a site using HTTPS. However, when you are manually connecting to sites (using HTTP requests manually), all that work still needs to be done. Now I don't know what all this work is exactly, but it has to do with downloading certificates and putting them where Java can find them. Here's a link that will hopefully point you in the right direction.

java - How to connect via HTTPS using Jsoup? - Stack Overflow

java android https web-scraping jsoup
Rectangle 27 0

I'm no expert in this field but I ran into a similar exception when trying to connect to a website over HTTPS using java.net APIs. The browser does a lot of work for you regarding SSL certificates when you visit a site using HTTPS. However, when you are manually connecting to sites (using HTTP requests manually), all that work still needs to be done. Now I don't know what all this work is exactly, but it has to do with downloading certificates and putting them where Java can find them. Here's a link that will hopefully point you in the right direction.

java - How to connect via HTTPS using Jsoup? - Stack Overflow

java android https web-scraping jsoup
Rectangle 27 0

t.run();

Calling run method using t object of Timetable class instead of starting Thread.

download.start();

java - android.os.NetworkOnMainThreadException on trying to connect wi...

java android jsoup