Advertisement
Guest User

Untitled

a guest
Apr 13th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. public class test
  2. {
  3. public static void main(String[] args) throws IOException{
  4. final String USER_AGENT = ""Mozilla/5.0 (Windows NT" +n" +
  5. " " 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"";
  6. String loginFormUrl = "https://jira.aciworldwide.com/login.jsp";
  7. String loginActionUrl = "https://jira.aciworldwide.com/login.jsp";
  8. String username = "jon@jon";
  9. String password = "XXXXXX";
  10.  
  11. HashMap<String, String> cookies = new HashMap<>();
  12. HashMap<String, String> formData = new HashMap<>();
  13.  
  14. Connection.Response loginForm = Jsoup.connect(loginFormUrl).method(Connection.Method.GET).userAgent(USER_AGENT).execute();
  15. Document loginDoc = loginForm.parse(); // this is the document that contains response html
  16.  
  17. cookies.putAll(loginForm.cookies()); // save the cookies, this will be passed on to next request
  18.  
  19. formData.put("login", "Log In");
  20. formData.put("os_username", username);
  21. formData.put("os_password", password);
  22.  
  23. Connection.Response homePage = Jsoup.connect(loginActionUrl)
  24. .cookies(cookies)
  25. .data(formData)
  26. .method(Connection.Method.POST)
  27. .userAgent(USER_AGENT)
  28. .execute();
  29.  
  30. System.out.println(homePage.parse().html());
  31.  
  32.  
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement