12,162
社区成员
发帖
与我相关
我的任务
分享
VHttpPost post = new VHttpPost("https://kyfw.12306.cn/passport/web/login");
VParames parames = new VParames();
parames.put("username", Page.userNameFidld.getText());
parames.put("answer", newCode);
parames.put("appid", "otn");
parames.put("password", new String(Page.passwordField.getPassword()));
VHeader vHeader = new VHeader();
vHeader.put("User-Agent","Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0"); // 设置请求头消息User-Agent)
post.setHeader(vHeader);
// AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.26 Safari/537.36
// Core/1.63.6824.400 QQBrowser/10.3.3127.400\"");
post.setParames(parames);
VHttpResponse res = VBrowser.execute(post);
String body = VHttpUtils.outHtml(res.getBody()); // 将网页内容转为文本
try {
JSONObject json = new JSONObject(body);
if ("0".equals(json.get("result_code").toString())) {
// JSONObject json2 = new JSONObject(json.get("data").toString());
// if (json2.length()>1 && "Y".equals(json2.get("loginCheck").toString())) {
Page.msgLabel.setText("登录成功,正在跳转到主页");