I have this url http://www.zara.com/qr/1260020210042
and I am trying to get the redirected final URL:
String url = "http://www.zara.com/qr/1260020210042";
Response response = Jsoup.connect(url).followRedirects(true).execute();
String url2 = response.url().toString();
Response response2 = Jsoup.connect(url2).followRedirects(true).execute();
System.out.println(response2.url());
but it doesn't print the final redirected URl , what shall I change? Thanks,
EDIT:
I tried also with Htmlunit but it doesn't give me the final link which I need:
WebClient webClient = new WebClient(BrowserVersion.FIREFOX_45);
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getOptions().setRedirectEnabled(true);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setCssEnabled(true);
HtmlPage page = (HtmlPage) webClient.getPage("http://www.zara.com/qr/1260020210042");
WebResponse response = page.getWebResponse();
String content = response.getContentAsString();
System.out.println(page.getUrl());