日期:2014-05-20 浏览次数:20754 次
import java.net.*; import java.io.*; public class testUrl { public static void main(String[] args) { StringBuffer document = new StringBuffer(); try { URL url = new URL("http://scholar.google.com.hk/scholar?hl=zh-CN&q=Still+stratus+not+altocumulus%3A+further+evidence+against+the+date%2Fparty+hub+distinction&lr=&as_ylo=&as_vis=1"); URLConnection conn = url.openConnection(); conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line = null; while ((line = reader.readLine()) != null) document.append(line + " "); reader.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println(document.toString()); } }