4
回答
httpclient怎么不能成功注册百度或是各论坛
极速云服务器,低至1.04元/天>>>   

不能注册成功

 

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

public class SimpleHttpPut { 
	public static void main(String[] args) {
		
		HttpClient client = new DefaultHttpClient();
		HttpPost post = new HttpPost("https://passport.baidu.com/?reg");
		try {
			List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(6);
			nameValuePairs.add(new BasicNameValuePair("acc","wia11kai"));
			nameValuePairs.add(new BasicNameValuePair("pas","aa11bb22cc"));
			nameValuePairs.add(new BasicNameValuePair("u_pas1","aa11bb22cc"));
			nameValuePairs.add(new BasicNameValuePair("sex","1"));
			nameValuePairs.add(new BasicNameValuePair("mail","123abc456@kwi.com"));
			nameValuePairs.add(new BasicNameValuePair("verifycode","此处为打开百度注册页面后显示的验证码手动填写的"));
			post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
			HttpResponse response = client.execute(post);
			HttpEntity entity = response.getEntity();
			System.out.println(response.getStatusLine());
			if(entity != null){
				System.out.println("Response content length:" +entity.getContentLength());
				String content = EntityUtils.toString(entity);
				System.out.println("Resonse content:"+content);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			client.getConnectionManager().shutdown();
		}
	}
}

举报
得瑟来的
发帖于6年前 4回/638阅
共有4个答案 最后回答: 5年前
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

public class SimpleHttpPut { 
	public static void main(String[] args) {
		
		HttpClient client = new DefaultHttpClient();
		HttpPost post = new HttpPost("http://www.jueaivip.com/register.php?regsubmit=yes");
		try {
			List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(4);
			nameValuePairs.add(new BasicNameValuePair("username","wia11kai"));
			nameValuePairs.add(new BasicNameValuePair("password","aa11bb22cc"));
			nameValuePairs.add(new BasicNameValuePair("password2","aa11bb22cc"));
			nameValuePairs.add(new BasicNameValuePair("email","123abc456@kwi.com"));
			post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
			HttpResponse response = client.execute(post);
			HttpEntity entity = response.getEntity();
			System.out.println(response.getStatusLine());
			if(entity != null){
				System.out.println("Response content length:" +entity.getContentLength());
				String content = EntityUtils.toString(entity);
				System.out.println("Resonse content:"+content);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			client.getConnectionManager().shutdown();
		}
	}
}

顶部