日期:2014-05-17 浏览次数:20866 次
public String loadPage(String url)
{
String data = null;
System.out.println("Requesting: " + url);
try {
HttpGet httpget = new HttpGet(url);
httpget.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
httpget.setHeader("Accept-Encoding", "gzip,deflate,sdch");
httpget.setHeader("Accept-Language", "zh-CN,zh;q=0.8,en;q=0.6");
httpget.setHeader("Cache-Control", "max-age=0");
httpget.setHeader("Connection", "keep-alive");
httpget.setHeader("Host", "movie.douban.com");
httpget.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36");
HttpResponse response = httpClient.execute(httpget);
System.out.println(response.getStatusLine());
data = EntityUtils.toString(response.getEntity());
// httpget.releaseConnection();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return data;
}