From: Ahmed A. <asa...@ya...> - 2014-09-10 06:57:49
|
Hi, - You shouldn't disabled throwing exception on failing status code. - I didn't get any error when running that code. Ahmed ________________________________ From: "htm...@li..." <htm...@li...> To: htm...@li... Sent: Tuesday, September 9, 2014 6:36 PM Subject: Auto-discard notification ----- Forwarded Message ----- The attached message has been automatically discarded. Hi, I try to extract data from : http://www.machinerytrader.com/ web is automatic forward to: http://www.marketbook.com/map/default.aspx I try to get back page: http://www.machinerytrader.com/ But my code doesn’t work. Here is my code: String url= "http://www.machinerytrader.com/"; final WebClient webClient = new WebClient(BrowserVersion.CHROME); webClient.getCookieManager().setCookiesEnabled(true); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setRedirectEnabled(true); webClient.getOptions().setCssEnabled(true); webClient.setWebConnection(new HttpWebConnection(webClient) { public WebResponse getResponse(WebRequest settings) throws IOException { WebResponse response = null; try { response = super.getResponse(settings); } catch(Exception e) { webClient.setJavaScriptTimeout(35000); response = super.getResponse(settings); } return response; } }); // HtmlPage market_Book_Page = webClient.getPage(url); //USA area HtmlMap map = market_Book_Page.getHtmlElementById("FPMap0"); List<HtmlArea> area_List = map.getElementsByAttribute("area", "", ""); HtmlArea usa_Area = area_List.get(7); HtmlPage p = usa_Area.click(); // HtmlAnchor anchor = p.getAnchorByHref("http://www.machinerytrader.com") ; HtmlPage category_Page = anchor.click(); |