Htmlunit for a specific script

0

Good morning.

I'm trying to block a specific script in HtmlUnit (Java) that is not letting other information access, I've tried this code, but when I give a print page.asXml () it continues to block page content.

Code used:

WebClient web = new WebClient(BrowserVersion.CHROME);
     new FalsifyingWebConnection(web) {
        @Override
        public WebResponse getResponse(WebRequest settings) throws IOException {
            System.out.println(settings.getUrl().toExternalForm());

            if (settings.getUrl().toString().contains("js/visualizador-pdf.js?")) {
                return createWebResponse(null, "", "text/javascript");
            }


            return super.getResponse(settings);
        }
    };

Thank you!

    
asked by anonymous 26.06.2018 / 15:09

0 answers