java http 请求几种工具
Jsoup
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
</dependency>
String url = "http://www.baidu.com";
Connection conn = Jsoup.connect(url).method(Connection.Method.Get);
Connection.Response response = connection.execute();
System.out.println(response.body());
okhttp
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>2.7.5</version>
</dependency>
String url = "http://www.baidu.com";
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().get().url(url).build();
Call call = client.newCall(request);
Response response = call.execute();
System.out.println(response.body().string());