httpclient相关的jar包:
commons-codec-1.9
commons-logging-1.2
fluent-hc-4.5.1
httpclient-4.5.1
httpclient-cache-4.5.1
httpclient-win-4.5.1
httpcore-4.4.3
httpmime-4.5.1
jna-4.1.0
共有 9个jar包。
第一步:先new一个client:
DefaultHttpClient client = new DefaultHttpClient();
//url是网址,表示将要发送一个get请求到该网址,
HttpGet httpget = new HttpGet(url);
//让client执行这个get请求,返回response
HttpResponse response = client.execute(httpget);
//获取这一个 链接的CookieStore,
CookieStore cookieStore = client.getCookieStore();
//CookieStore有一个方法,可以获取cookie集合
List cookies=cookieStore.getCookies();
//获取 响应后的html
HttpEntity entity = response.getEntity();
文章标题
最新推荐文章于 2022-06-12 17:07:04 发布