package GouPenn; import java.io.IOException; import org.apache.http.HttpEntity; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; public class MuYouGou { public static void main(String[] args) throws ClientProtocolException, IOException { // 创建httpclient 实例 CloseableHttpClient httpclient = HttpClients.createDefault(); // 创建httpGet 实例 HttpGet httpget = new HttpGet("https://pan.baidu.com/disk/home?errno=0&errmsg=Auth%20Login%20Sucess&&bduss=&ssnerror=0#list/path=%2F&vmode=list"); // 设置请求头消息 User—Agent httpget.setHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0"); //执行get 请求 CloseableHttpResponse res = httpclient.execute(httpget); HttpEntity hEnty = res.getEntity(); System.err.println("=======================请求内容开始:======================="); System.out.println(EntityUtils.toString(hEnty,"utf-8")); System.err.println("=======================请求内容结束:======================="); res.close(); } }
最近下载更多