67,513
社区成员
发帖
与我相关
我的任务
分享
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
public class CopyOfTest {
private static String userName = "woaihuoqiu1@163.com";
private static String password = "1qaz2wsx";
private static String url = "http://www.juxiangyou.com/login.php?act=loginDo";
private static String put28url ="http://game.juxiangyou.com//luck28/betting.php?a=664271";
public static void main(String[] args) throws Exception {
postLogin();
}
public static void postLogin() throws ClientProtocolException, IOException{
//第一次,登录主页
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
List <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair("tbUserAccount", userName));
nvps.add(new BasicNameValuePair("tbUserPwd", password));
nvps.add(new BasicNameValuePair("isChkCode", "0"));
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
CloseableHttpResponse response = httpclient.execute(httpPost);
try {
System.out.println(response.getStatusLine());
HttpEntity entity = response.getEntity();
String loginEntityContent = EntityUtils.toString(entity);
System.out.println(loginEntityContent);
if (loginEntityContent.contains("result\":200")) {//登录成功
System.out.println("loginEntityContent true");
//登录成功后,进行自动投注
HttpPost httpPost1 = new HttpPost(put28url);
nvps = getParams2();//设置post提交参数,就是这里有问题,不知设置哪些参数
httpPost1.setEntity(new UrlEncodedFormEntity(nvps));
CloseableHttpResponse lucky28resp = httpclient.execute(httpPost1);
entity = lucky28resp.getEntity();
loginEntityContent = EntityUtils.toString(entity,"gb2312");
System.out.println(loginEntityContent);
}
EntityUtils.consume(entity);
} finally {
response.close();
}
}
public static ArrayList <NameValuePair> getParams(){
ArrayList <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair("tbLuck28Chk[0]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[1]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[2]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[3]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[4]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[5]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[6]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[7]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[8]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[9]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));//10
nvps.add(new BasicNameValuePair("tbLuck28Chk[10]", "on"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", "1"));
nvps.add(new BasicNameValuePair("tbLuck28Chk[11]", "on"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", "1"));
nvps.add(new BasicNameValuePair("tbLuck28Chk[12]", "on"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", "1"));
nvps.add(new BasicNameValuePair("tbLuck28Chk[13]", "on"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", "1"));
nvps.add(new BasicNameValuePair("tbLuck28Chk[14]", "on"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", "1"));
nvps.add(new BasicNameValuePair("tbLuck28Chk[15]", "on"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", "1"));
nvps.add(new BasicNameValuePair("tbLuck28Chk[16]", "on"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", "1"));
nvps.add(new BasicNameValuePair("tbLuck28Chk[17]", "on"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", "1"));// 8
nvps.add(new BasicNameValuePair("tbLuck28Chk[18]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[19]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[20]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[21]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[22]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[23]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[24]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[25]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[26]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Chk[27]", "off"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));//10
return nvps;
}
public static ArrayList <NameValuePair> getParams1(){
ArrayList <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair("tbLuck28Chk[0]", "on"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", "10"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));//10
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));// 8
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", ""));//10
return nvps;
}
public static ArrayList <NameValuePair> getParams2(){
ArrayList <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair("tbLuck28Chk[0]", "on"));
nvps.add(new BasicNameValuePair("tbLuck28Value[]", "10"));
return nvps;
}
}