在java中使用HTTPURLConnection加载更多数据

时间:2015-06-01 19:35:52

标签: twitter httpurlconnection twitter4j httpconnection

在我的程序中,我使用HTTPURLConnection读取数据,例如

  URL url = new URL("https://twitter.com/search?q="+kw+"%20lang%3Aeng%20"+"&src=typd&lang=en");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();

    conn.setRequestMethod("GET");
    conn.setRequestProperty("Accept", "application/json");

    if (conn.getResponseCode() != 200) {
        throw new RuntimeException("Failed : HTTP error code : "
                + conn.getResponseCode());
    }

    String line;
    StringBuilder builder = new StringBuilder();
    BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    while ((line = reader.readLine()) != null) {
        builder.append(line);
        builder.append("\n");
    }
    String html = builder.toString();

问题只是在响应页面上读取数据,但我需要读取所有可以检索的数据

如何在结果页面中加载更多数据

0 个答案:

没有答案