我正在研究通過數據庫(特定紐約時報在線數據庫http://query.nytimes.com/search/sitesearch/#/McCain/from20061201to20080603/allresults/1/allauthors/oldest/)html代碼解析以查找某些關鍵字的項目,但它從Oracle獲取的代碼無法獲取完整的HTML。我已經能夠使用此代碼之前的其他項目,所以我不知道爲什麼它不讀取所有的HTML。在Java中獲取完整的HTML
謝謝:)
URL oracle = new URL("http://query.nytimes.com/search/sitesearch/#/McCain/from20061201to20080603/allresults/1/allauthors/oldest/");
URLConnection yc = oracle.openConnection();
yc.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream()));
System.out.println(yc.getContentType());
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
你什麼意思「不工作」和「完整的HTML」呢? – pvg
我的意思是我的項目只打印掉部分HTML,並且缺少我想要的HTML部分,我懷疑這是因爲該網頁正在加載 –
對不起,太模糊了 –