From: Jack Bi <814...@qq...> - 2014-02-26 14:38:06
|
Hi all: Because of htmlUnit is very slow, so I thought of using httpclient to obtain page code. But the HTML code that I got is not I wanted, page with JS code need to be executed. I would like to know how to use htmlUnit execute the code. This is my code: HttpPost httpPost = new HttpPost(urlString); List<NameValuePair> formparams = new ArrayList<NameValuePair>(); formparams.add(new BasicNameValuePair(inputName, "https://twitter.com")); formparams.add(new BasicNameValuePair(selectName,optionValue)); httpPost.setEntity(new UrlEncodedFormEntity(formparams,HTTP.UTF_8)); HttpResponse response = httpClient.execute(httpPost); entity = response.getEntity(); htmlString = EntityUtils.toString(entity,HTTP.UTF_8); URL url = new URL(urlString); StringWebResponse webResponse = new StringWebResponse(htmlString, url); HtmlPage page = HTMLParser.parseHtml(webResponse, webClient.getCurrentWindow()); Thread.sleep(20*1000); But it cannot work.How can I do? Thank you very much! Jack -- View this message in context: http://htmlunit.10904.n7.nabble.com/How-to-use-htmlUnit-execution-of-type-String-HTML-page-tp33241.html Sent from the HtmlUnit - General mailing list archive at Nabble.com. |