String url = "xx.jsp";WebClient wc = new WebClient(BrowserVersion.CHROME);wc.getCookieManager().setCookiesEnabled(true);wc.setAjaxController(new NicelyResynchronizingAjaxController());WebRequest request = new WebRequest(new URL(url));WebResponse response = wc.loadWebResponse(request);System.out.println(response.getContentAsString());// HtmlPage page = HTMLUnitUtil.getHTMLPageByURL(wc, url, false);////// // 获取页面元素// HtmlForm form = page.getForms().get(0);//// HtmlInput company = form.getInputByName("companyCode");// company.setValueAttribute("xx");//// HtmlInput userID = form.getInputByName("userID");// userID.setValueAttribute("xx");//// HtmlImage goImg = form.getOneHtmlElementByAttribute("img", "name", "goImg");//// Page temp = goImg.click();拿到的temp还是之前的page内容
添加回答
举报
0/150
提交
取消