簡體   English   中英

如何在Java博士中導入HTTPClient?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM