[英]How to import HTTPClient in Dr. Java?
我正在尝试编写代码来抓取网站并使用httpclient。 我正在尝试导入适当的类以运行我的程序,但这是说该软件包不存在。 我查看了他们的API试图找出答案,但仍然无法解决。 我的代码是:
import java.io.IOException;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import java.util.Scanner
public class Scraper3 {
public static String scrapeWebsite() throws IOException {
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet("http://ichart.finance.yahoo.com/table.csv?s=MSFT");
HttpResponse response = client.execute(get);
HttpEntity entity = response.getEntity();
if (entity != null) {
Scanner scanner = new Scanner(entity.getContent());
while (scanner.hasNextLine()) {
System.out.println(scanner.nextLine());
}
}
}
}
尝试: org.apache.http.client.HttpClient
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.