Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class test
- {
- public static void main(String[] args) throws IOException{
- final String USER_AGENT = ""Mozilla/5.0 (Windows NT" +n" +
- " " 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"";
- String loginFormUrl = "https://jira.aciworldwide.com/login.jsp";
- String loginActionUrl = "https://jira.aciworldwide.com/login.jsp";
- String username = "jon@jon";
- String password = "XXXXXX";
- HashMap<String, String> cookies = new HashMap<>();
- HashMap<String, String> formData = new HashMap<>();
- Connection.Response loginForm = Jsoup.connect(loginFormUrl).method(Connection.Method.GET).userAgent(USER_AGENT).execute();
- Document loginDoc = loginForm.parse(); // this is the document that contains response html
- cookies.putAll(loginForm.cookies()); // save the cookies, this will be passed on to next request
- formData.put("login", "Log In");
- formData.put("os_username", username);
- formData.put("os_password", password);
- Connection.Response homePage = Jsoup.connect(loginActionUrl)
- .cookies(cookies)
- .data(formData)
- .method(Connection.Method.POST)
- .userAgent(USER_AGENT)
- .execute();
- System.out.println(homePage.parse().html());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement