模拟网页登陆成功后跳转怎么实现

2024-12-03 16:30:32
推荐回答(1个)
回答(1):

1
2
3

HttpResponse responce = httpClient.execute(httpGet,localContext);
HttpEntity entity = responce.getEntity();
EntityUtils.toString(entity,"UTF-8");

2、通过jsoup解析出token

?

1
2

Document doc = Jsoup.parse(html);
Elements elements =doc.select("input");

最后取出认证成功的cookie
?

1
2
3
4

httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8"));
CloseableHttpResponse response = httpClient.execute(httpPost, localContext);
String postResult = EntityUtils.toString(response.getEntity(), "UTF-8");
List cookies = localContext.getCookieStore().getCo