Search code examples
javahtmlhtmlunit

What is the <cbn-root> html element? And how to parser it by Java?


I was trying to write a Java program to monitor if there are reserved spots becoming available on this website: https://www.drpciv.ro/drpciv-booking/formular/23/exchangingForeignDriverLicence

But when I view page source with Chrome or Edge, the body part show only <cbn-root></cbn-root>. But using Chrome's Inspect function I can see the complete body. When I try to get the content of the webpage in Java with HtmlUnit it gets only <cbn-root></cbn-root> and no real content either.

Tried to google <cbn-root>, but didn't see any useful information. Wonder what the element is and how to read the real content in Java in this case.

Thank you


Solution

  • At least with the upcoming version 2.43.0 the tag gets replaced.

    public static void main(String[] args) throws IOException {
        String url = "https://www.drpciv.ro/drpciv-booking/formular/23/exchangingForeignDriverLicence";
    
        try (final WebClient webClient = new WebClient(BrowserVersion.FIREFOX)) {
            webClient.getOptions().setThrowExceptionOnScriptError(false);
    
            HtmlPage page = webClient.getPage(url);
            System.out.println(" ---- ");
            webClient.waitForBackgroundJavaScript(10_000);
    
            System.out.println(" ---- ");
            System.out.println(page.asXml());
        }
    }