From: Ahmed A. <asa...@ya...> - 2013-12-17 10:53:59
|
Hi, >> The "getPage" do not do this job It should! HtmlUnit automatically recursively process all JavaScript. Please read [1] and [2] If you still want to see the .JS and save them yourself, you can use: WebClient webClient = new WebClient(); new WebConnectionWrapper(webClient) { public WebResponse getResponse(WebRequest request) throws IOException { WebResponse response = super.getResponse(request); String url = request.getUrl().toExternalForm(); String content = response.getContentAsString(); return response; } }; webClient.getPage("http://www.google.com"); Thread.sleep(10000); Yours, Ahmed [1] http://htmlunit.sourceforge.net/faq.html#AJAXDoesNotWork [2] http://htmlunit.sourceforge.net/submittingJSBugs.html ________________________________ From: 赵芮元 <zry...@16...> To: htmlunit群邮件 <htm...@li...> Sent: Tuesday, December 17, 2013 1:43 PM Subject: [Htmlunit-user] loading and extracting javascripts(.js files) Hi, When we use the function webClient.getPage("http://www.google.com") for example, we get the html page of Google. Numbers of javascripts codes are embeded in it. Some of the js codes are embeded directly in the html page while some of them are in the form like this <script src="http://su.bdimg.com/static/superpage/js/sbase_3963a90b.js"></script> which needs further request for the source code of it. The "getPage" do not do this job. But in normal browsers fetch all the javascrips and execute them. Then my question is, how to extract all these javascript files to my file system in a web page such as "www.google.com" by using htmlunit? Thanks a lot! Yours, Zhao Ruiyuan ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ Htmlunit-user mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |