我将如何继续使用通过使用 Apache 的 httpcomponents 获得的登录会话在需要您登录的站点上使用 html(代码方式)?
这是我使用 httpcomponents 时的样子:
HttpPost httpost = new HttpPost("http://whatever.com/login.php");
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("email", "whatever")); //set your own username
nvps.add(new BasicNameValuePair("password", "whatever")); //set your own password
httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
HttpResponse response = httpclient.execute(httpost);
HttpEntity entity = response.getEntity();
我认为我的问题的答案在于 HttpEntity 类的某个地方,但我觉得我被困住了..
澄清一下:如上所示登录后,我需要使用上面的会话访问一个页面,该页面需要您登录(例如 membersonly.php 或其他),然后阅读和使用内容从 Java 中的这个页面开始。
希望我让自己足够清楚:) 期待任何答案。
麦克风