33 lines
1.2 KiB
Java
33 lines
1.2 KiB
Java
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import java.io.InputStream;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.URL;
|
|
import java.util.Scanner;
|
|
|
|
public class CheckRender {
|
|
public static void main(String[] args) {
|
|
try {
|
|
URL url = new URL("http://localhost:8080/");
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
conn.setRequestMethod("GET");
|
|
conn.connect();
|
|
if (conn.getResponseCode() == 200) {
|
|
InputStream is = conn.getInputStream();
|
|
Scanner scanner = new Scanner(is, "UTF-8").useDelimiter("\\A");
|
|
String html = scanner.hasNext() ? scanner.next() : "";
|
|
|
|
int idx = html.indexOf("news-card__image");
|
|
if (idx != -1) {
|
|
System.out.println(html.substring(idx, Math.min(idx + 300, html.length())));
|
|
} else {
|
|
System.out.println("Could not find news-card__image in HTML");
|
|
}
|
|
} else {
|
|
System.out.println("HTTP " + conn.getResponseCode());
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|