我很难找到解决这个问题的方法,所以我希望你能帮助我。我正在使用HTTPost登录网站。我可以成功登录,但仍然存在问题。登录时,它首先将我带到一个“中间人页面”,将我重定向到主页面,主页似乎使用Window.onLoad
函数来重定向我。当我获得响应的HTML时,它将获取重定向页面的HTML。该网站使用会话来保持我的登录,而不是cookie。我只需要获取我重定向到的FINAL页面的HTML。这是我的代码。谢谢。
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(
"https://secure.groupfusion.net/processlogin.php");
String HTML = "";
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);
nameValuePairs
.add(new BasicNameValuePair(
"referral_page",
"/modules/gradebook/ui/gradebook.phtml?type=student_view&sessionid=16beb2d321c8c845b751022a196dbeb1"));
nameValuePairs.add(new BasicNameValuePair("currDomain",
"beardenhs.knoxschools.org"));
nameValuePairs.add(new BasicNameValuePair("username", username
.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("password", password
.getText().toString()));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
String g = httppost.getURI().toString();
HttpResponse response = httpclient.execute(httppost);
HTML = EntityUtils.toString(response.getEntity());
sting.setText(HTML);