我有代码填写参数,然后提交网络表单。
我想添加一项功能,即如果表单中有验证码,则验证码会显示在屏幕上,最终用户会填写此值。现在表单已正确提交到目的地。 我知道一些应用程序,如Java中的Link Assistant,以及Delphi中的GSA Website Submitter,我想知道如何实现它。
Java中的代码-----
package post;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpPostForm
{
public static void main(String[] args)
{
try
{
URL url = new URL( "http://www.aaaa.com/xyz.asp" );
HttpURLConnection hConnection = (HttpURLConnection)
url.openConnection();
HttpURLConnection.setFollowRedirects( true );
hConnection.setDoOutput( true );
hConnection.setRequestMethod("POST");
PrintStream ps = new PrintStream( hConnection.getOutputStream() );
ps.print("param1=abcd&param2=10341");
ps.close();
hConnection.connect();
if( HttpURLConnection.HTTP_OK == hConnection.getResponseCode() )
{
InputStream is = hConnection.getInputStream();
OutputStream os = new FileOutputStream("output.html");
int data;
while((data=is.read()) != -1)
{
os.write(data);
}
is.close();
os.close();
hConnection.disconnect();
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}