import java.io.*;
class pro{
String urlx,data,bun,file;
String str1,str2;
int[] x=new int[100000];
int[] y=new int[100000];
int s,xmlnumber;
String xml[]=new String[100000];
String credit[]=new String[100000];
int n,p1,p2;
public static void main(String [] args) {
pro test=new pro();
}
pro(){
for(n=2;n<50;n++){
urlx="http://ameblo.jp/miniskirt-hirahira/page-";
urlx=urlx+n;
urlx=urlx+".html";
getdata gt=new getdata();
gt.makedata(urlx);
data=gt.data;
xymaker(data);
xmlmaker(data);
creditmaker(data);
str1="entryBottom";
str2="entry_head";
p1=0;
p2=0;
for(s=1;s<xmlnumber+1;s++){
if(xml[s].indexOf(str2)>-1)p1=s;
if(xml[s].indexOf(str1)>-1)p2=s;
}
System.out.println(p1);
System.out.println(p2);
bun="";
for(s=p1;s<p2;s++){
bun=bun+credit[s];
}
System.out.println(bun);
file=n+".txt";
makefile(file,bun);
}
}
void creditmaker(String str){
int s,p1,p2;
for(s=1;s<xmlnumber;s++){
p1=y[s];
p2=x[s+1];
if(p2>p1)credit[s]=str.substring(p1+1,p2);
}
}
void xmlmaker(String str){
int s,p1,p2;
for(s=1;s<xmlnumber+1;s++){
p1=x[s];
p2=y[s];
xml[s]=str.substring(p1+1,p2);
}
}
void xymaker(String str){
int p1;
int s;
s=1;
p1=str.indexOf("<");
x[1]=p1;
while(p1>-1){
p1=str.indexOf("<",p1+1);
if(p1>-1)s=s+1;
if(p1>-1)x[s]=p1;
}
xmlnumber=s;
for(s=1;s<xmlnumber+1;s++){
y[s]=str.indexOf(">",x[s]);
}
}
void makefile(String file,String bun){
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
pw.println(bun);
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
}
最終更新:2011年04月19日 23:33