Java uses multithreading, curl, and proxy IP to simulate post submission and get access to Cainiao. it is easy to write and play with multiple threads. you can pass by and instruct me. thank you! * ** @ Component name: javaDemo * @ package name: javaDemo * @ File name: Jenny. java * @ creation Time: 5:53:48, January 1, August 1, 2014 * @ copyright: Copy
Using multithreading, curl, and proxy IP in Java to simulate post submission and get access
Cainiao: It's fun to write and play with multiple threads. you can pass by and give me some advice. thank you!
/*** @ Component name: javaDemo * @ package name: javaDemo * @ File name: Jenny. java * @ creation Time: 5:53:48, January 1, August 1, 2014 * @ Copyright: Copyright©2014 eelly Co. Ltd: copyright of the uncle. */Package javaDemo; import java. io. bufferedReader; import java. io. file; import java. io. fileWriter; import java. io. IOException; import java. io. inputStreamReader; import java. io. printWriter; import java. io. writer; import java.net. URL; import java.net. URLConnection; import java. util. list; import java. util. map; import java. util. random;/*** is defined for Exception throw. because Exception cannot be thrown, only subclasses can */class MyException extends Exception {private static final long serialVersionUID =-1485825968429580934L; public MyException () {super ();} public MyException (String msg) {super (msg);} public MyException (String msg, Throwable cause) {super (msg, cause);} public MyException (Throwable cause) {super (cause );}} /*** The Thread class required by a sister-in-law */class ShiMengRen implements Runnable {/*** Page Views */private String url =" http://www.shimengren.com/article/yj/views.jhtml ";/*** Click the link */private String urlZan =" http://www.shimengren.com/article/yj/ups.jhtml ";/*** Travelogue ID */private String param =" article_id = 10844 "; /*** global variable shared by multiple threads * // private volatile boolean flag = true; /*** number of threads submitted by the post operation */private static final int MAX_THREAD_COUNT = 25; /*** counter for the number of threads submitted by post */private volatile static int threadNum = 0;/*** count */private static int num = 0; /***** browsing times */private static int view = 0;/***** proxy IP */private String [] proxyArray = {"127.0.0.1: 8787", "115.239.210.199: 80 "," 149.20.242: 80 "," 124.172.242.175: 80 "," bandwidth: 80 "," 183.234.59.89: 18186 "," bandwidth: 80 "," 183.224.1.56: 80 ", "120.202.249.230: 80", "125.46.100.198: 9999", "clerk: 8080", "202.96.172.234: 808", "clerk: 80", "clerk: 80", "222.66.115.229: 80 "}; // public void setFlag (boolean flag) {// this. flag = flag; //} // public boolean getFlag () {// return this. flag; //} // public void stop () {// this. setFlag (false); // public void start () {// this. setFlag (true); //} public void setNum (int num) {ShiMengRen. num = num;} public int getNum () {return ShiMengRen. num;} public void setThreadNum (int threadNum) {ShiMengRen. threadNum = threadNum;} public int getThreadNum () {return ShiMengRen. threadNum;} public int getView () {return ShiMengRen. view;}/*** @ method name: getProxy * @ description: randomly obtains the proxy IP address * @ creator: