package crawler;
import org.apache.http.client.*;
import org.apache.http.client.methods.*;
class Crawler{
public static void main(String args[]){
HttpClient httpclient = new HttpClient(); // **HERE!!!!!!!!!**
GetMethod getMethod = new GetMethod("http://www.google.com");
int statusCode = httpclient.executeMethod(getMethod);
System.out.println("response=" + getMethod.getResponseBodyAsString());;
getMethod.releaseConnection();
}
}
来自 Apache Httpclient 的 HttpClient。
编码:
@SuppressWarnings("deprecation")
public interface HttpClient
如何解决问题“ HttpClient httpclient = new HttpClient();
”?谢谢!
HttpClient
是一个接口。YTou不能这样做。
正确的做法是
HttpClient client = HttpClientBuilder.create().build();
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句