html文档,可试运行下,<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head><body>
<form action="http://passport.sohu.com/sso/setcookie.jsp?ru=http%3A%2F%2Fsde.game.sohu.com%2Floginok.jsp%3Ffrom%3Di%26backurl%3D%252F&[email protected]&appid=1015&ct=1236761877&code=ed53c7d94a3190b84d28588e9cb549e7" method="post">
<input name="" type="submit" value="提交">
</form></body>
</html>java 代码import org.apache.commons.httpclient.Cookie;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;public class FormLoginDemo33 { static final String LOGON_SITE = "http://www.sohu.com/";
static final int LOGON_PORT = 80; public static void main(String[] args) throws Exception {
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT);
String ul = "http://passport.sohu.com/sso/setcookie.jsp?ru=http%3A%2F%2Fsde.game.sohu.com%2Floginok.jsp%3Ffrom%3Di%26backurl%3D%252F&[email protected]&appid=1015&ct=1236761877&code=ed53c7d94a3190b84d28588e9cb549e7"; PostMethod post = new PostMethod(ul);
client.executeMethod(post);
String responseString = new String(post.getResponseBodyAsString()
.getBytes("gbk"));
System.out.println(responseString);
Cookie[] cookies = client.getState().getCookies();
client.getState().addCookies(cookies);
post.releaseConnection(); System.out.println("**************第1次转向后的页面***************");
GetMethod get = new GetMethod(
"http://sde.game.sohu.com/loginok.jsp?from=i&backurl=%2F&status=0");
get.setRequestHeader("Cookie", cookies.toString());
client.executeMethod(get);
responseString = new String(get.getResponseBodyAsString().getBytes(
"gbk"));
System.out.println(responseString);
get.releaseConnection(); System.out.println("**************第2次转向后的页面***************");
get = new GetMethod("http://sde.game.sohu.com/lndex.jsp");
get.setRequestHeader("Cookie", cookies.toString());
client.executeMethod(get);
responseString = new String(get.getResponseBodyAsString().getBytes(
"gbk"));
System.out.println(responseString);
get.releaseConnection(); }
}输出的结果不是预期的,请教高手指点!