2012-06-19 26 views
0

可能重複:
How can you search Google Programmatically Java API提取URL

我需要提取使用Java的谷歌搜索結果的網址。我做的第一步是使用提取整個html頁面文本的代碼。

不幸的是,這段代碼沒有適用於谷歌。有沒有解決方案從谷歌結果頁面使用Java代碼提取網址?我已閱讀關於谷歌自定義搜索API。我的問題是:是否有可能在Java中使用它?任何線索?

URL url = new URL("http://type the search result url here"); 
URLConnection connection = url.openConnection(); 
connection.setDoInput(true); 
InputStream inStream = connection.getInputStream(); 
BufferedReader input = 
new BufferedReader(new InputStreamReader(inStream)); 
String line = ""; 
while ((line = input.readLine()) != null) 
System.out.println(line); </i> 
+2

http://stackoverflow.com/questions/3727662/how-can-you-search-google-programmatically-java-api – maksimov

回答