import java.io.*;
class pro{
String urlx,data,file;
int[] x=new int[10000];
int[] y=new int[10000];
String xml[]=new String[10000];
String credit[]=new String[10000];
int s,h,xmlnumber;
String str1,str2,str3;
String bun;
int p1,p2,p3,q1,q2;
int j;
int page;
public static void main(String [] args) {
pro test=new pro();
}
pro(){
for (page=1;page<50;page++){
urlx="http://saayaworld.blog70.fc2.com/blog-entry-";
urlx=urlx+page;
urlx=urlx+".html";
getdata gt=new getdata();
gt.makedata(urlx);
data=gt.data;
xymaker(data);
for(s=1;s<xmlnumber+1;s++){
xml[s]=xmlmaker(s,data);
}
for(s=1;s<xmlnumber;s++){
credit[s]=creditmaker(s,data);
}
for(s=1;s<xmlnumber;s++){
if(credit[s].indexOf("banner")>-1)p1=s;
if(credit[s].indexOf("comments")>-1)p2=s;
}
System.out.println(p1);
System.out.println(p2);
j=0;
if(p1<0)j=100;
if(p2<0)j=100;
if(p1>p2)j=100;
while(j<50){
bun="";
for(s=p1+1;s<p2;s++){
bun=bun+credit[s];
}
j=100;
}
System.out.println(bun);
file=page+".txt";
makefile(file,bun);
}
}
String xmlmaker(int s,String str){
int p1,p2;
String bara;
p1=x[s];
p2=y[s];
bara=str.substring(p1+1,p2);
return bara;
}
String creditmaker(int s,String str){
int p1,p2;
String bara;
bara="";
p1=y[s];
p2=x[s+1];
if(p2>p1)bara=str.substring(p1+1,p2);
return bara;
}
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日 03:10