java - HtmlUnit not loading dynamic content -
i trying products loaded dynamically scrolling e-commerce website polyvore.com using htmlunit ajax requests. page source code obtained doesn't have dynamically generated products.
here htmlunit code:
try { string url = "http://www.polyvore.com/jewelry/shop?category_id=60"; webrequest req = new webrequest(new url(url)); webclient webclient = new webclient(browserversion.firefox_38); webclient.getoptions().setcssenabled(false); webclient.getoptions().setappletenabled(false); webclient.getoptions().setthrowexceptiononscripterror(false); // ssl support webclient.getoptions().setuseinsecuressl(true); // ajax support webclient.setajaxcontroller(new nicelyresynchronizingajaxcontroller()); webclient.waitforbackgroundjavascriptstartingbefore(600*1000); webclient.getcurrentwindow().setinnerheight(60000); htmlpage page = webclient.getpage(req); string content = page.getwebresponse().getcontentasstring(); system.out.println(content); } catch (exception e) { throw new runtimeexception(e); }
you can generate custom http requests achieve task. htmlunit supports this.
first capture traffic emulate using htmlunit.
Comments
Post a Comment