登录后如何在我的个人资料上发表评论Jodd
?httpclient
final HttpBrowser browser = new HttpBrowser();
HttpRequest request = HttpRequest.get("www.facebook.com");
browser.sendRequest(request);
String page = browser.getPage();
Jerry doc = Jerry.jerry(page);
// process login form
doc.form("#login_form", new JerryFormHandler() {
public void onForm(Jerry form, Map<String, String[]> parameters) {
String formAction = form.attr("action");
HttpRequest loginRequest = HttpRequest.post(formAction);
for (Map.Entry<String, String[]> entry : parameters.entrySet()) {
String[] values = entry.getValue();
String name = entry.getKey();
for (String value : values) {
loginRequest.form(name, value);
}
}
// overwrite form parameters
loginRequest.form("email", "your-email-here", true);
loginRequest.form("pass", "your-password-here", true);
browser.sendRequest(loginRequest);
}
});
// this is your personal page:
System.out.println(browser.getPage());