Connection conn1 = Jsoup.connect(url);
conn1.method(Method.GET);
conn1.followRedirects(false);
Response response = conn1.execute();
System.out.println(response.cookies());
cookies.put("JSESSIONID", response.cookies().get("JSESSIONID"));
cookies.put("user_flag", "dVdscllTOWR1emp3SXAxem1QamJ2UT09");
conn1 = Jsoup.connect(url).cookies(cookies);
// 设置请求类型
Document doc = null;
switch (requestType)
{
case Rule.GET:
doc = conn1.timeout(100000).get();
break;
case Rule.POST:
doc = conn1.timeout(100000).post();
break;
}
//doc可以获取到,继续使用刚才的cookie
conn1 = Jsoup.connect(url).cookies(cookies);
switch (requestType)
{
case Rule.GET:
doc = conn1.timeout(100000).get();
break;
case Rule.POST:
doc = conn1.timeout(100000).post();
break;
}
//doc提示重新登录
//获取到的JSESSIONID是会话期的,浏览器关闭后才会变,怎么使得第一次获取到的JSESSION还能用
分享至: