Я пытаюсь проверить recaptcha из веб-просмотра, однако приложение не проверяет.
public class WebViewBrowser extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
WebView browser = new WebView();
WebEngine webEngine = browser.getEngine();
URI uri = URI.create(url);//url is a valid address
Map<String, List<String>> headers = new LinkedHashMap<String, List<String>>();
headers.put("Set-Cookie", Arrays.asList("APISID=E2mcDXOq7ze9A2Vg/Ar9qIklbtuxLfJA1Z", "CONSENT=YES+DE.de+20160612-12-0", "HSID=AZqBaYgd1dLE0PVXI"));
try {
java.net.CookieHandler.getDefault().put(uri, headers);
} catch (IOException e) {
e.printStackTrace();
}
webEngine.setUserAgent("use required / intended UA string");
webEngine.setJavaScriptEnabled(true);
com.sun.javafx.webkit.WebConsoleListener.setDefaultListener(
(webView, message, lineNumber, sourceId)
-> System.out.println("Console: [" + sourceId + ":" + lineNumber + "] " + message)
);
webEngine.load(url);
primaryStage.setTitle(webEngine.getLocation());
StackPane root = new StackPane();
root.getChildren().add(browser);
primaryStage.setMaximized(true);
primaryStage.setScene(new Scene(root, 600, 600));
primaryStage.show();
}
При запуске приложения у нас есть следующие журналы:
Console: [null:0] The source list for Content Security Policy directive 'script-src' contains an invalid source: ''nonce-CKSHgRdQFCsx4VRpta1wcA''. It will be ignored.
Console: [null:0] The source list for Content Security Policy directive 'script-src' contains an invalid source: ''strict-dynamic''. It will be ignored.
Console: [null:0] Unrecognized Content-Security-Policy directive 'base-uri'.