I want to connect https url using Jsoup I followed How to connect via HTTPS using Jsoup??

But now I am getting

Exception in thread "main" org.jsoup.HttpStatusException: HTTP error fetching URL. Status=401, URL=myurl
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:435)
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:410)
    at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:164)
    at org.jsoup.helper.HttpConnection.get(HttpConnection.java:153)
    at FIndItNow.main(FIndItNow.java:27)

Any idea how to fix this ?

I am calling like

Document doc = Jsoup.connect(myurl).userAgent("Mozilla").get();
有帮助吗?

解决方案

As error 401 says it is an UNAUTHORIZED request. It seems you need send some authentication headers in the request. Either you are not sending them or those are not correct.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top