public static void main(String[] args)
throws FailingHttpStatusCodeException, MalformedURLException,
IOException
{
WebClient client = new WebClient();
client.setThrowExceptionOnScriptError(false);// important
HtmlPage page = client.getPage("http://www.baidu.com/");
String content = page.getWebResponse().getContentAsString();
System.out.println(content);
//选择百度首页的"注册"超链接
HtmlAnchor registerAnchor = page.getAnchorByName("tj_reg");
HtmlPage registerPage = registerAnchor.click();//点击注册超链接,返回注册页的html
String con = registerPage.getWebResponse().getContentAsString();
System.out.println(con);
}
throws FailingHttpStatusCodeException, MalformedURLException,
IOException
{
WebClient client = new WebClient();
client.setThrowExceptionOnScriptError(false);// important
HtmlPage page = client.getPage("http://www.baidu.com/");
String content = page.getWebResponse().getContentAsString();
System.out.println(content);
//选择百度首页的"注册"超链接
HtmlAnchor registerAnchor = page.getAnchorByName("tj_reg");
HtmlPage registerPage = registerAnchor.click();//点击注册超链接,返回注册页的html
String con = registerPage.getWebResponse().getContentAsString();
System.out.println(con);
}