使用HTMLUNIT获取Google建议的关键字

时间:2012-12-12 16:28:25

标签: java keyword htmlunit

当您在搜索字段中输入时,我正在尝试使用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());

关于我如何表现的任何想法?

0 个答案:

没有答案