当您在搜索字段中输入时,我正在尝试使用HTMLUNIT来获取Google建议的关键字。这是我的代码:
final WebClient webClient = new WebClient(BrowserVersion.CHROME_16);
webClient.setJavaScriptEnabled(true);
webClient.setThrowExceptionOnScriptError(false);
webClient.setCssEnabled(false);
webClient.setUseInsecureSSL(true);
webClient.setRedirectEnabled(true);
GenerateCsv gcsv=new GenerateCsv();
HtmlPage googlePage = webClient.getPage(new URL("http://www.google.com/"));
HtmlInput searchEl=googlePage.getElementByName("q");
searchEl.type("hello");
googlePage.refresh();
//loginPage.getElementById("gbqfba").click();
System.out.println(googlePage.asText());
关于我如何表现的任何想法?