HttpURLConnection.getInputStream() を使用して Web ページをダウンロードし、コンテンツを文字列に取得するには、次の方法を実行します。
String content="";
isr = new InputStreamReader(pageContent);
br = new BufferedReader(isr);
try {
do {
line = br.readLine();
content += line;
} while (line != null);
return content;
} catch (Exception e) {
System.out.println("Error: " + e);
return null;
}
ページのダウンロードは高速ですが、コンテンツを String に取得する処理は非常に低速です。コンテンツを文字列に取得するための別の方法はありますか?
これを String に変換してデータベースに挿入します。