使用Jsoup到登录后的数据 [英] Using Jsoup to POST login data
本文介绍了使用Jsoup到登录后的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图登录到这个网站: http://deeproute.com
I'm trying to log into this website: http://deeproute.com
这是我的code。
Connection.Response res = null;
Connection homeConnection = null;
Document homePage = null;
Map<String, String> loginCookies = null;
try {
res = Jsoup.connect("http://www.deeproute.com/")
.data("cookieexists", "false")
.data("name", user)
.data("password", pswd).method(Method.POST)
.execute();
} catch (IOException e) {
e.printStackTrace();
}
if (res != null) {
loginCookies = res.cookies();
try {
homePage = Jsoup.connect("http://www.deeproute.com")
.cookies(loginCookies).get();
} catch (IOException e) {
e.printStackTrace();
}
不幸的是,这只是简单地返回同一页面中一个不登录的状态。我究竟做错了什么?
Unfortunately, this simply returns the same page in a not-logged-in state. What am I doing wrong?
推荐答案
您需要发布之前阅读的形式!你缺少参数subbera =登录。
You need to read form before posting! You are missing param subbera=Login.
public static void main(String[] args) throws Exception {
Connection.Response loginForm = Jsoup.connect("http://deeproute.com/deeproute/default.asp")
.method(Connection.Method.GET)
.execute();
Document document = Jsoup.connect("http://deeproute.com/deeproute/default.asp")
.data("cookieexists", "false")
.data("name", "username")
.data("password", "pass")
.data("subbera", "Login")
.cookies(loginForm.cookies())
.post();
}
这篇关于使用Jsoup到登录后的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文