アットウィキロゴ

tw4

package tw3;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

public class pro {
  public static void main(String[] args) throws Exception {
    pro client = new pro();
    String xml = client.execute("日経ソフトウエア");
    System.out.println(xml);
  }

  public String execute(String keyword) throws Exception {
    String url = "http://search.twitter.com/search.atom?q=" + keyword;
    HttpClient httpClient = new DefaultHttpClient();
    HttpGet httpGet = new HttpGet(url);
    HttpResponse response = httpClient.execute(httpGet);
    HttpEntity entity = response.getEntity();
    if (entity != null) {
      return EntityUtils.toString(entity);
    } else {
      return null;
    }
  }
}
最終更新:2011年08月20日 20:42