import java.io.*;
class pro{
String urlx,file;
String data[]=new String[5000];
String article[]=new String[5000];
int s,sx,datanumber;
int[] st=new int[10];
int[] en=new int[10];
int articlenumber,number;
String str1,str2,bun;
int page,t;
public static void main(String [] args) {
pro test=new pro();
}
pro(){
t=0;
for(page=1;page<13;page++){
urlx="http://blog.livedoor.jp/rindab/?p=";
urlx=urlx+page;
getdata gt=new getdata();
gt.makedata(urlx);
data=gt.data;
datanumber=gt.datanumber;
str1="article-body entry-content";
str2="articleBody End";
sx=0;
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf(str1)>0)sx=sx+1;
if(data[s].indexOf(str1)>0)st[sx]=s;
}
number=sx;
sx=0;
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf(str2)>0)sx=sx+1;
if(data[s].indexOf(str2)>0)en[sx]=s;
}
for(s=1;s<number+1;s++){
bun="";
for(sx=st[s]+1;sx<en[s];sx++){
bun=bun+data[sx];
}
t=t+1;
article[t]=bun;
System.out.println(bun);
}
}
articlenumber=t;
writefile();
}
void writefile(){
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter("article.txt")));
for(s=1;s<articlenumber;s++){
pw.println(article[s]);
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
}
最終更新:2011年07月14日 11:13