繁体   English   中英

Android应用程序不显示已解析的Jsoup信息

[英]Android app does not display parsed Jsoup information

我在AsyncTask类中有以下代码(目的是登录到我的学生成绩簿,检索成绩,并现在输出到日志):

private class infoGetter extends AsyncTask<Void, Void, Void> {


    @Override
    protected Void doInBackground(Void... params) {


        String studentID = studentID2.getText().toString();
        String username = user.getText().toString();
        String password = pass.getText().toString();

        String loginURL = "https://parents.mtsd.k12.nj.us/genesis/parents/j_security_check";
        String userDataUrl = "https://parents.mtsd.k12.nj.us/genesis/parents?module=" + module + "&action=" + action + "&mpToView=" + mp + "&studentid=" + studentID;

        Connection.Response res = null;
        Document doc = null;

        try {

            res = Jsoup.connect(userDataUrl)
                    .userAgent("Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.4 Safari/537.36")
                    .header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
                    .timeout(500)
                    .method(Connection.Method.GET)
                    .execute();

            Log.e("connecting","first connection");

        } catch (IOException io) {

            io.printStackTrace();

        }

        try {

            doc = Jsoup.connect(loginURL)
                    .userAgent("Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.4 Safari/537.36")
                    .referrer("https://parents.mtsd.k12.nj.us/genesis/parents?gohome=true")
                    .cookies(res.cookies())
                    .data("j_username", username)
                    .data("j_password", password)
                    .post();

            Log.e("connecting","second connection");


        } catch (IOException ioe) {

            ioe.printStackTrace();

        }

        Log.e("connecting","about to check if doc is null");

        if (doc != null){

            Log.e("MESSAGE","doc is not null");

            //everything works fine up to here!!

            Elements fGrade = doc.select("[width=70%]");

            for(Element e : fGrade) {

                Log.e("Grade: ",e.text());
            }
        }
        return null;
    }
}
}

但是,在运行我的应用程序并登录(正确的凭据)后,我根本没有收到任何包含成绩的日志消息。 我的Jsoup代码应该正确,因为我使用java作为我的应用程序的序言创建了一个测试项目,该项目运行良好。 但是,我不知道我在做什么错!

一如既往地感谢所有帮助!

更新:因此,使用不同的日志,我已将错误范围缩小到使用“ doc.select()”调用周围/之后的某个位置。 但是,我仍然没有发现任何错误。

好吧,原来我的学校决定更新他们的成绩簿的UI,所以我的查询实际上是不正确的。 一切正常,更新查询。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM