简体   繁体   English

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

[英]Android app does not display parsed Jsoup information

I have the following code in an AsyncTask class (purpose to log in to my student gradebook, retrieve grades, and for now output to log): 我在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;
    }
}
}

However, upon running my app and logging in (correct credentials), I do not get any log messages containing my grades at all. 但是,在运行我的应用程序并登录(正确的凭据)后,我根本没有收到任何包含成绩的日志消息。 My Jsoup code should be correct, as I created a test project using java as a preface to my app, which worked flawlessly. 我的Jsoup代码应该正确,因为我使用java作为我的应用程序的序言创建了一个测试项目,该项目运行良好。 However, I have no idea what I'm doing wrong! 但是,我不知道我在做什么错!

All help is appreciated as always! 一如既往地感谢所有帮助!

UPDATE: So using different logs, I have narrowed down the error to a point somewhere around/after where I am using the "doc.select()" invocation. 更新:因此,使用不同的日志,我已将错误范围缩小到使用“ doc.select()”调用周围/之后的某个位置。 However, I still don't see anything wrong.. 但是,我仍然没有发现任何错误。

Well, turns out my school decided to update their gradebook's UI so my query was actually incorrect. 好吧,原来我的学校决定更新他们的成绩簿的UI,所以我的查询实际上是不正确的。 Everything working fine with updated query. 一切正常,更新查询。

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

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