我試圖訪問以下網站的內容:http://paraphrase.org/以便通過查詢,不幸的是我沒有得到內容(檢索答案)。我將非常感謝任何幫助,這裏是我的代碼;我試圖訪問該網站的內容:http://paraphrase.org/#/search?q=tree&filter=&lang=en
import java.net.*;
import java.io.*;
public class PPdbURL {
public static void main(String args[]) throws URISyntaxException{
String nextLine;
URL url = null;
URLConnection urlConn = null;
InputStreamReader inStream = null;
BufferedReader buff = null;
try{ // Create the URL obect that points at the default file index.html
url = new URL("http://paraphrase.org/#/search?q=tree&filter=&lang=en");
urlConn = url.openConnection();
inStream = new InputStreamReader(urlConn.getInputStream());
buff= new BufferedReader(inStream); // Read and print the lines from
//index.html
while (true){
nextLine =buff.readLine();
if (nextLine !=null){
System.out.println(nextLine);
}
else{
break;
}
}
}
catch(MalformedURLException e)
{
System.out.println("Please check the URL:" + e.toString());
}
catch(IOException e1){
System.out.println("Can't read from the Internet: "+ e1.toString());
}
}
}
你想說什麼?例外?無內容? – JustinKSU
我試圖發佈輸出,但它太長了。基本上它只是html,但最後指出的元素與Java腳本有關: – Soxell