I want to download the content of the page: https://www.hafen-hamburg.de/en/vessels/klein-erna/. In my code and DevTools I can see that I'm getting a 500 error:
but I can also clearly see in the browser that the page has been loaded. How can I download the content of the page despite this error?
My code:
String pageUrl = "https://www.hafen-hamburg.de/en/vessels/klein-erna/";
URL url = new URL(pageUrl);
String content = IOUtils.toString(url, StandardCharsets.UTF_8);
thanks for your comment (@egeorge) I used the HttpClient library and got exactly what I wanted.
Code:
String pageUrl = "https://www.hafen-hamburg.de/en/vessels/klein-erna/";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder().uri(URI.create(pageUrl)).build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());