如何使用jsoup登录后提交表单

时间:2016-10-13 12:31:00

标签: jsoup

我正在编写一个查看日程安排的应用程序,但我遇到了一个问题:我无法抓住我想要的网址。这是我的代码。    我已经解决了这个问题。

Connection.Response res=Jsoup.connect("http://regis.agu.edu.vn/default.aspx?page=dangnhap")
                    .method(Connection.Method.GET)
                    .execute();
            Document doc=res.parse();
            Document Login=Jsoup.connect("http://regis.agu.edu.vn/Default.aspx")
                    .data("__EVENTTARGET","")
                    .data("__EVENTARGUMENT","")
                    .data("__VIEWSTATE",doc.getElementById("__VIEWSTATE").val())
                    .data("ctl00$ContentPlaceHolder1$ctl00$ucDangNhap$txtTaiKhoa","dth135165")
                    .data("ctl00$ContentPlaceHolder1$ctl00$ucDangNhap$txtMatKhau","01694215528")
                    .data("ctl00$ContentPlaceHolder1$ctl00$ucDangNhap$btnDangNhap","Ðăng Nhập")
                    .cookies(res.cookies())
                    .post();
            t2=doc.getElementById("__VIEWSTATE").val();
            Connection.Response testRequest = Jsoup.connect("http://regis.agu.edu.vn/default.aspx?page=thoikhoabieu&sta=0")
                    .method(Connection.Method.GET)
                    .followRedirects(false) // <-- did the trick
                    .cookies(res.cookies())
                    .execute();
            Document res1=testRequest.parse();
            Document tkb=Jsoup.connect("http://regis.agu.edu.vn/default.aspx?page=thoikhoabieu&sta=0")
                    .data("__EVENTTARGET","")
                    .data("__EVENTARGUMENT","")
                    .data("__LASTFOCUS","")
                    .data("__VIEWSTATE",res1.getElementById("__VIEWSTATE").val())
                    .data("ctl00$ContentPlaceHolder1$ctl00$ddlChonNHHK","20161")
                    .data("ctl00$ContentPlaceHolder1$ctl00$ddlLoai","0")
                    .data("ctl00$ContentPlaceHolder1$ctl00$ddlTuan","Tuần 09 [Từ 10/10/2016 -- Đến 16/10/2016]")
                    .data("ctl00$ContentPlaceHolder1$ctl00$btnDt","Tuần Đầu")
                    .cookies(res.cookies())
                    .post();

以下是params的屏幕截图。

0 个答案:

没有答案