0

I am using the gui-less browser htmlunits to retrieve the webcontent for webpages and the code is working fine for other sites except "http://www.xyzzzzzzz.com.sg/". Can anybody explain why this is happening???? I already used HtmlUnit webdriver for all three browsers CHROME, FIREFOX and IE as BrowserVersion, nothing is working.

public class Test{

    public static void main(String[] args) throws Exception {

        String url = "http://www.xyzzzzzzz.com.sg/";

        WebClient webClient = new WebClient(BrowserVersion.CHROME);
        webClient.getOptions().setCssEnabled(false);
        webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
        webClient.getOptions().setThrowExceptionOnScriptError(false);
        webClient.getCookieManager().setCookiesEnabled(true);
        webClient.getOptions().setUseInsecureSSL(true);

        HtmlPage currentPage = (HtmlPage) webClient.getPage(url);
        String content = currentPage.asXml();
        webClient.waitForBackgroundJavaScript(20000);

        System.out.println(content); // NOT SHOWING PROPER CONTECT
    }
}
Shashank
  • 712
  • 15
  • 33
  • I researched a lot and tried lot of available options. With HtmlClient it is throwing 416 error but with browser its working fine that's why i am using HtmlUnit for this. Please suggest some solution – Shashank Jan 06 '14 at 02:59

1 Answers1

0

Cab you please describe what do you mean by NOT SHOWING PROPER CONTECT.Because I dnt think there is some mistake in code. Some time JS makes problem to HtmlUnit for execution so check by stopping it too.

Kick
  • 4,823
  • 3
  • 22
  • 29
  • plz replace xyzzzzzz as jobstreet in the url mention in the code and then you will find out that what SOP is printing is not same as the content available on their site. – Shashank Jan 07 '14 at 02:05