There are some important methods in this jar package, including the function of encapsulating http requests. This article provides a reference;
[Java]
Import java. io. IOException;
Import org. apache. commons. httpclient. HttpClient;
Import org. apache. commons. httpclient. HttpException;
Import org. apache. commons. httpclient. methods. PostMethod;
Public class TestLogin {
Public static void main (String [] args) throws Exception, IOException {
TestLogin. testLogin ();
}
Public static void testLogin () throws HttpException, IOException {
HttpClient client = new HttpClient ();
String url = "https://reg.163.com/logins.jsp ";
PostMethod method = new PostMethod (url );
// Method. addParameter ("type", "1 ");
// Method. addParameter ("url ","");
// Method. addParameter ("product", "urs ");
Method. addParameter ("username", "xxxxxxx@126.com ");
Method. addParameter ("password", "xxxxxx ");
Client.exe cuteMethod (method );
String response = method. getResponseBodyAsString ();
System. out. println (response );
}
}