gpt4 book ai didi

java - Android如何解析XHTML

转载 作者:行者123 更新时间:2023-12-02 07:02:55 25 4
gpt4 key购买 nike

我有一个计划在创建自动登录服务后进行android web解析...但我有一个问题...我尝试解析http://communion.gntc.net/我看到 www.w3.org/xhtml...xhtml...如何进行自动登录服务...只是我知道使用“post方法”登录

<小时/>

Image[Click]

源尝试该网址连接并尝试登录,但我无法登录。只是...再次登录读取流源屏幕...ma​​in.java(部分)

public class Main extends SherlockActivity {
........

public class async_Login extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
try {
// URL setting
communion_Url = new URL("http://communion.gntc.net/Default.aspx");
connection = (HttpURLConnection) communion_Url .openConnection();

// <Form> setting
connection.setRequestProperty("content-type", "application/x-www-form-urlencoded");

// method choose
connection.setRequestMethod("POST");

// transfer mode
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setDefaultUseCaches(false);

// server input info
StringBuffer buffer = new StringBuffer();
buffer.append("__VIEWSTATE").append("=").append("%2FwEPDwUKLTIyMDExNjMxNA9kFgICAw9kFgICAw9kFgICBw9kFgICAQ9kFgICCQ8QZGQWAGQYAgUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFFExvZ2luVmlldzEkaWJ0bkxvZ2luBRZMb2dpblZpZXcxJG12TG9naW5WaWV3Dw9kZmQyduUiycnsslmd80DsHFWnE%2F5ewQ%3D%3D").append("&");
buffer.append("__EVENTVALIDATION").append("=").append("%2FwEWBAK%2F9LzRAwK73JjWBAKVqtrbDwLeooalDbXptfMUzAby%2FyAzoqPXkmhJ%2Bq6x").append("&");
buffer.append("LoginView1%24txtID").append("=").append(params[0]).append("&"); //ID values
buffer.append("LoginView1%24ibtnLogin.x").append("=").append("1").append("&");
buffer.append("LoginView1%24ibtnLogin.y").append("=").append("1").append("&");
buffer.append("LoginView1%24txtPW").append("=").append(params[1]); // PS values
fileSave(buffer.toString());
OutputStream opstrm = new BufferedOutputStream(connection.getOutputStream());
opstrm.write(buffer.toString().getBytes());
opstrm.flush();
opstrm.close();

connection.setRequestMethod("GET");
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer response = new StringBuffer();
while((line = rd.readLine()) != null) {
response.append(line);
response.append('\r');
}
rd.close();

//fileSave(response.toString());
Log.i("#async_Login#", response.toString());
} catch (IOException e) {
Log.i("##async_Login##", "Communion Connect Failure");
//e.printStackTrace();
}

return null;
}

@Override
protected void onPostExecute(String result) {

}
}

.........
}

最佳答案

您正在使用 GET 方法:connection.setRequestMethod("GET"); 尝试将其更改为 POST。

关于java - Android如何解析XHTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16424647/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com