我正在尝试编写代码来抓取网站并使用 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());
}
}
}
}