Forum Irrigation Machine

zhaozj2021-02-11  165

This article is how to make a forum irrigation machine, which is tested for a large real estate forum. It is a JIVE3-based forum. If the forum has joined picture certification to log in, this program will lose its role.

This program uses httpclient package, download address: http://www.innovation.ch/java/httpclient/

The principle of irrigation machine is very simple. It is the form of the analysis forum. It can be submitted with its own procedure to simulate it. The purpose of this article is to introduce this open source tool for HTTPClient, from JDK .NET package strength, HttpClient features multiple operations Re-use the same connection, set the connection timeout (based on socket), use the proxy verification. Specifically, you can see comparison data to the Innovation website. The following is a simple program of the Irrigation program, for reference only import java.net. *; Import java.io. *; Import java.util. *; Import httpclient. *;

class WebRequester {private static InputStream istr = null; private static OutputStream ostr = null; private static NVPair form_data []; private static HTTPConnection httpCon; private static HTTPResponse rsp; private static String host; private static WebRequester instance; private WebRequester () {} public static WebRequester getInstance () {if (instance == null) {instance = new WebRequester ();} return instance;} public static String request (HTTPConnection connection, String pathName, String method, nVPair form_data []) {try {httpCon = Connection; IF (). Equals ("get") {if (form_data! = null) RSP = httpcon.get (Pathname, Form_Data); Else Rsp = httpcon.get (Pathname);} else} IF (form_data! = null) rsp = httpcon.post (pathname, form_data); Else Rsp = httpcon.post (pathname);} istr = rsp.getinputStream (); bufferedreader reader = new bufferedReader new InputStreamReader (istr)); String line; StringBuffer result = new StringBuffer (); while ((line = reader.readLine ())! = null) {result.append (line System.getProperty ( "line.separator") );};} Catch (exception e) {} return ";}}

public class Flood {private HTTPConnection connection; public Flood () {getConnection ( "sitename.com", 80);} public void releaseConnection () {if (connection = null!) {connection.stop (); connection = null;} } public HTTPClient.HTTPConnection getConnection (String hostName, int port) {if (connection == null) {try {connection = new HTTPClient.HTTPConnection (hostName, port); HTTPClient.CookieModule.setCookiePolicyHandler (null); connection.addDefaultModule (Class .forName ( "HTTPClient.CookieModule"), 1); connection.addModule (Class.forName ( "HTTPClient.RedirectionModule"), 2);} catch (Exception e) {e.printStackTrace ();}} return connection;} Public void Post (String Subject, String Body) {nvpair [] form_data = new nvpair [5]; form_data [0] = new nvpair ("forumID", "87"); form_data [1] = new nvpair ("Subject" , Subject); Form_Data [2] = New NVPAIR ("Classifier", "- 1"); form_data [3] = new nvpair ("body", body); f ORM_DATA [4] = New NVPAIR ("Dopost", "Published"); WebRequest ("post! post.jspa", "post", form_data);} public void reply (String Thread, "POST, FORM_DATA); String Subject, String Body) {// How many items need to submit a form, view the reply page form You can get nvpair [] form_data = new nvpair [7]; form_data [0] = new nVPAIR ("ForumID", "87"); form_data [1] = new nVPAIR ("Subject", Subject); Form_Data [2] = New NVPAIR ("Classifier", "- 1"); form_data [3] = New NVPAIR ("Body", Body); Form_Data [4 ] = new nvpair ("reply", "true");

Form_data [5] = New NVPAIR ("ThreadID", Thread); Form_Data [6] = New NVPAIR ("DOPOST", "Published"); WebRequester.getInstance (). Request (Connection, "Post! Post.jspa", "post", form_data);} public void finish () {releaseConnection ();} public void login () {WebRequester WR = WebRequester.getInstance (); nvpair [] form_data = new nvpair [4]; // correspondence Form_Data [0] = New NVPAIR ("FormuserName", "User"); form_data [1] = new nVPAIR ("FormPassword", "pass"); form_data [2] = New NVPAIR ("Formlogins CRIPT" "Sitename.com/loginuser.jsp"); form_data [3] = new nvpair ("forumlogin", "y"); // Submit to the specified landing page Wr.Request (connection, "cgi-bin / gzhome / registration /Loginuser1.jsp", "Post " (Connection, "INDEX.JSPA", "Get", NULL;

转载请注明原文地址:https://www.9cbs.com/read-5777.html

New Post(0)