public static void main(String[] args) {
getHtml("http://news.qq.com",null);
}
public static CloseableHttpResponse getHtml(String url,String cookie) {
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(
new AuthScope("202.194.232.132",10010 ),
new UsernamePasswordCredentials("qf", "qf3.1415"));
CookieStore cookieStore = null;
CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).setDefaultCookieStore(cookieStore).build();
HttpGet hp = new HttpGet(url);
HttpHost proxy = new HttpHost("202.194.232.132", 10010);
RequestConfig config = RequestConfig.custom()
.setSocketTimeout(10000).setConnectTimeout(10000).
setProxy(proxy).build();
CloseableHttpResponse response = null;
System.out.println("开始 请求 !
httpClient4.5.3 代理设置账号
最新推荐文章于 2023-10-31 15:48:07 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)