We know that when sending get data, we can add parameters after the file name, such as http://www.mz520.com/bbs/post.asp?action=new&banadid=41
The next action = new & boardID = 41 is the value received by the GET method. To submit the first method of the POST data, you can use JavaScript's form.submit () method to simulate form commit, the second method is to use the URL class object setting in the NET package. Output stream is done, first create a URL object (here the 9CBS login processing page as an example)
URL URL = New URL ("http://www.9cbs.net/member/logon.asp");
UrlConnection Connection = URL.OpenConnection (); // Then open a data stream to get the returned HTML
Connection.SetDoOutput (True); // Set the output stream
OutputStreamWriter out = new outputStreamWriter ()); // Get output stream
Out.write ("Login_Name = Umbrella1984 & Password = 123456 & Cookietime = 0"); // Output POST Data
Out.flush ();
Out.close ();
This way is sent out, and you can use GetInputStream () to get the page HTML code when logging in to success or failure.
BufferedReader IN = New BufferedReader (New InputStreamRead); // Setting the input stream, in order to get the return HTML
String html_value;
While (in.readline ()! = null) {// If the returned page is not empty
HTML_VALUE = HTML_VALUE IN.Readline (); // Get all HTML
}
System.out.println (HTML_VALUE);
In.Close ();