I'm been searching for this issue, supposedly this problem is fixed using an user agent, but this is not the case.
what i'm trying to do is to fetch the cookies from a petition, this the code
note: i'm try to do the petition to https webpage
/*obtiene cookies de la peticion*/
Connection.Response res = Jsoup.connect(liga).header("Content-Type","text/html;charset=UTF-8")
.cookie("TALanguage", "ALL")
.data("mode", "filterReviews")
.data("filterRating", "")
.data("filterSegment", "")
.data("filterSeasons", "")
.data("filterLang", "ALL")
.referrer(liga)
.header("X-Requested-With", "XMLHttpRequest")
.header("X-Puid",xpuid)
.data("returnTo",returnTo)
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
.method(Method.POST)
.execute();
doc = res.parse();
Map<String, String> cookies = res.cookies();
the program fails at the line .execute();
with this error in the log:
org.jsoup.HttpStatusException: HTTP error fetching URL. Status=403, URL=https://somepage.html
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:459)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:434)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:181)
at mx.oeste.crawler.htmlunit.obtenerComentarios(htmlunit.java:82)
at mx.oeste.crawler.htmlunit.main(htmlunit.java:40)