2014-01-02 6 views
3

Я пытаюсь получить доступ к тексту какой-либо страницы, которая требует от меня входа в систему в первую очередь.Моя процедура входа в систему работает некорректно

страница Войти в = https://utdirect.utexas.edu/

и моя попытка до сих пор, как это,

Response res = Jsoup 
     .connect("https://utdirect.utexas.edu/") // this is the login page 
     .header("LOGON", "mySchoolID") 
     .header("PASSWORDS", "mySchoolIDPassword") 
     .method(Method.POST) 
     .execute(); 


    Map<String, String> loginCookies = res.cookies(); // cookies to keep me logged in 



    // This is the page that required me to be loged in first 
    Document doc = Jsoup.connect("https://utdirect.utexas.edu/apps/degree/audits/requests/history/") 
      .cookies(loginCookies).get(); 
     Elements e = doc.getAllElements(); 

     for(Element e1 : e){ 
      Log.i("e.text()" , e.text); 
     } 

Проблема заключается в том, что один, который распечатывается страница Войти НЕ страница, которую я хочу ,

Любая идея, каково решение этой проблемы?

ответ

2

Прочитайте регистрационную форму перед отправкой. Вам не хватает нескольких параметров. Проверьте их для каждого ведения журнала.


Connection.Response loginForm = Jsoup.connect("https://utdirect.utexas.edu/") 
       .ignoreContentType(true) 
       .userAgent("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0") 
       .referrer("http://www.google.com") 
       .timeout(12000) 
       .followRedirects(true) 
       .method(Connection.Method.GET) 
       .execute(); 

    Connection.Response loginFormFilled = Jsoup.connect("https://utdirect.utexas.edu/") 
       .ignoreContentType(true) 
       .userAgent("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0") 
       .followRedirects(true) 
       .referrer("https://utdirect.utexas.edu/") 
       .data("CDT","20140103191944") 
       .data("NEW_PASSWORD", "") 
       .data("CONFIRM_NEW_PASSWORD", "") 
       .data("LOGON", "user") 
       .data("PASSWORDS", "pass") 
       .cookies(loginForm.cookies()) 
       .method(Connection.Method.POST) 
       .execute(); 

    Map<String, String> cookies = loginFormFilled.cookies(); 
+0

и как именно я держать печенье для меня в состоянии получить доступ https://utdirect.utexas.edu/apps/degree/audits/requests/history/? Заранее спасибо! – user3134067

+0

Я обновил ответ. – user987339

Смежные вопросы