This commit is contained in:
2026-05-31 13:36:33 +05:00
parent 19f6475573
commit 94d47092af
7 changed files with 208 additions and 0 deletions

30
WebLoader.java Normal file
View File

@@ -0,0 +1,30 @@
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class WebLoader {
private static final HttpClient CLIENT = HttpClient.newHttpClient();
public static String loadPage(String urlString) {
try {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(urlString))
.header("User-Agent", "Mozilla/5.0")
.GET()
.build();
HttpResponse<String> response = CLIENT.send(
request,
HttpResponse.BodyHandlers.ofString());
return response.body();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
return "";
}
}
}