求助大神,打算做个教务信息查询,可是POST返回的数据和浏览器的不一致

wghusw 2013-10-15 07:32:45
求助大神,打算做个教务信息查询,可是POST返回的数据和浏览器的不一致
Android虚拟机获取到的返回的部分信息为
10-15 11:27:29.701: V/test(401): <td>
10-15 11:27:29.711: V/test(401): <input name="para" type="hidden" id="para" value="0"/>
10-15 11:27:29.711: V/test(401): <input name="sortColumn" type="hidden" id="sortColumn" value=""/>
10-15 11:27:29.711: V/test(401): <input type="submit" name="Submit" class="button" value="查询">
10-15 11:27:29.711: V/test(401): </td>
10-15 11:27:29.711: V/test(401): </tr>
10-15 11:27:29.711: V/test(401): </table>
10-15 11:27:29.711: V/test(401): </form>
10-15 11:27:29.711: V/test(401): <br>
10-15 11:27:29.771: V/test(401): </center>
10-15 11:27:29.771: V/test(401): </body>
10-15 11:27:29.771: V/test(401): </html>

浏览器返回的却是
<input name="sortColumn" type="hidden" id="sortColumn" value=""/>
<input type="submit" name="Submit" class="button" value="查询">
</td>
</tr>
</table>
</form>
<br>
<table width="100%" class="datalist">
<tr>
<th>

其中红色部分就是我需要的数据,也就是成绩的信息表
使用各种方法模拟post,但是还是这样,缺少需要的信息
但是html是完整的

我的post核心代码
	public String get(Context context, String cookieVal, String surl,
String post,String method) throws Exception {
/**
* * 首先要和URL下的URLConnection对话。 URLConnection可以很容易的从URL得到。 *比如: // Using
* java.net.URL and //java.net.URLConnection
* */
URL url = new URL(surl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
/**
* * 然后把连接设为输出模式。URLConnection通常作为输入来使用,比如下载一个Web页。 *
* 通过把URLConnection设为输出,你可以把数据向你个Web页传送。下面是如何做:
* */
connection.setDoOutput(true); // 打开输出,向服务器输出参数(POST方式、字节)
connection.setDoInput(true);// 打开输入,从服务器读取返回数据
connection.setRequestMethod(method); // 设置登录模式为POST(字符串大写)
connection.setInstanceFollowRedirects(false);
// connection.set
connection.setRequestProperty("Cookie", cookieVal);// 设置登陆配置
// Content-Type: application/x-www-form-urlencoded
connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");// 设置登陆配置
/**
* 最后,为了得到OutputStream,简单起见,把它约束在Writer并且放入POST信息中,例如: ...
*/
OutputStreamWriter out = new OutputStreamWriter(
connection.getOutputStream(), "utf-8");
out.write(post); // post的关键所在!
connection.connect();
Log.v("test", connection.getHeaderFields().toString());
// 开始GET数据
String encoding = connection.getContentEncoding();
InputStream is = connection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(is, "utf-8"));
String ss = null;
String total = "";
while ((ss = bufferedReader.readLine()) != null) {
total += ss;
Log.v("test", ss);
}
bufferedReader.close();
return total;
}


这个是发送流
POST /academic/manager/score/studentOwnScore.do?groupId=&moduleId=2021 HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Referer: http://jw.djtu.edu.cn/academic/manager/score/studentOwnScore.do?groupId=&moduleId=2021
Accept-Language: zh-CN
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Host: jw.djtu.edu.cn
Content-Length: 58
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: JSESSIONID=74724FC4CF9B46A03BC6C89BED4BDBB5

year=33&term=¶=0&sortColumn=&Submit=%E6%9F%A5%E8%AF%A2

求大神指导,一直卡在这个,别的模块都能正常获取,唯独这个成绩查询无法实现
...全文
94 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
WM_JAWIN 2013-10-16
  • 打赏
  • 举报
回复
是不是编码不一致?

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧