Menu

Home

Ahmed Ashour

A java GUI-Less browser, which allows high-level manipulation of web pages, such as filling forms and clicking links; just getPage(url), find a hyperlink, click() and you have all the HTML, JavaScript, and Ajax are automatically processed.


Discussion

  • SERGIO MAURICIO TRAD JUNIOR

    Hi,
    I have been using HTMLUnit version 2.15 successfully for some time.
    However, a few days ago, my solution stopped working.
    For some reason the site is not loaded as it should.
    I have already tried to update the version of HTMLUNIT to the latest but unsuccessfully.
    cookies, no content ... What is wrong !?

    THE CODE....

    WebClient webClient = new WebClient();
    webClient.getOptions().setUseInsecureSSL(true);
    webClient.getOptions().setCssEnabled(false);
    webClient.getOptions().setJavaScriptEnabled(true);

        webClient.getOptions().setAppletEnabled(false);
        webClient.getOptions().setActiveXNative(false);     
        webClient.getOptions().setGeolocationEnabled(false);
        webClient.getOptions().setPopupBlockerEnabled(true);
    
        webClient.getOptions().setRedirectEnabled(false); //Evita o carregamento desnecessário de paginas       
        webClient.getOptions().setTimeout(TIMEOUT);
    
        webClient.getOptions().setPrintContentOnFailingStatusCode(false);
        webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);             
        webClient.getOptions().setThrowExceptionOnScriptError(false);
    

    WebRequest requestSettings = new WebRequest(new URL("http://cadastro.saude.gov.br"), HttpMethod.GET);
    Page page = webClient.getPage(requestSettings);
    WebResponse response = page.getWebResponse();

            String unAutzSessionId = getCookieValue(page.getUrl(), CADWEB_SESSIONID);
            System.out.println(unAutzSessionId);
    
     
  • danial idress

    danial idress - 3 days ago

    Bro, I feel your pain. HTMLUnit can be so finicky sometimes. Have you tried enabling redirects? Setting setRedirectEnabled(false) might be the culprit if the site relies on redirects for session setup. Also, double-check if the site updated their SSL certs or user-agent requirements. Sometimes the simplest fix is just spoofing a real browser user-agent. Hope this helps!

     

Log in to post a comment.