0

Hi i have searched the internet and stackoverflow all day without any solution! :(

My problem is:

I have to show some schedules in a app, and the data is stored on a webpage, normally on PC you visit the page, enter your id, and it shows the schedule...

but how do i get to the schedule without interacting with a webview or stuff like that? i have to save some specific html data after login...

i have tired with jsoup, but after login, then the url changes, and i dont know how to get it, therefore i tried with webview, but this didnt work either

please help :)

1 Answers1

0

public class getHTML extends AsyncTask{

   String words;

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

       try {
           final String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36";
           final String FORM_URL = "http://timetable.scitech.au.dk/apps/skema/VaelgElevskema.asp?webnavn=skema";
           final String SCHEDULE_URL = "http://timetable.scitech.au.dk/apps/skema/ElevSkema.asp";
           final String USERID = "201506426";

            // # Go to search page
           Connection.Response loginFormResponse = Jsoup.connect(FORM_URL)
                   .method(Connection.Method.GET)
                   .userAgent(USER_AGENT)
                   .execute();

            // # Fill the search form
           FormElement loginForm = (FormElement)loginFormResponse.parse()
                   .select("form").first();

            // ## ... then "type" the id ...
           Element loginField = loginForm.select("input[name=aarskort]").first();
           loginField.val(USERID);



            // # Now send the form
           Connection.Response loginActionResponse = loginForm.submit()
                   .cookies(loginFormResponse.cookies())
                   .userAgent(USER_AGENT)
                   .execute();

            // # go to the schedule
           Connection.Response someResponse = Jsoup.connect(SCHEDULE_URL)
                   .method(Connection.Method.GET)
                   .userAgent(USER_AGENT)
                   .execute();

           // # print out the body
           Element el = someResponse.parse()
                   .select("body").first();

            words = el.text();


           System.out.println(loginActionResponse.parse().html());


       } catch (IOException e) {
           e.printStackTrace();
       }
        return null;
   }


   @Override
   protected void onPostExecute(Void aVoid) {
       super.onPostExecute(aVoid);


       tv.setText(words);

       Toast.makeText(MainActivity.this, "DET VIRKER!", Toast.LENGTH_SHORT).show();

   }

}

  • this is what i have by now, it doesnt work. i think it maybe have something to do with cookies? if you guys want to know what it should return, then go to FORM_URL, then paste this: 201506426, and then it shows the schedule.. sorry for the bad english :D –  Nov 12 '17 at 15:45
  • when i run my code, it returns this: "Tilmeldinger for Missing parameter" –  Nov 12 '17 at 15:48