アットウィキロゴ

tれび

import java.io.*;

class ren{

String[] article=new String[1000];
String[][] actor=new String[500][100];
String[][] dir=new String[500][10];
String[][] pro=new String[500][10];
String[] title=new String[1000];
String[][] cp=new String[500][10];
String[][] writer=new String[500][10];
int[] actornumber=new int[500];
int[] dirnumber=new int[500];
int[] writenumber=new int[500];
int[] pronumber=new int[500];
int[] cpnumber=new int[500];
int[] ratenumber=new int[500];
String[][] num=new String[500][50];
String[][] rate=new String[500][50];
String[][] date=new String[500][50];
int s,page;
int xlong,datanumber,articlenumber;
String bun,str;

public static void main(String [] args) {
        ren test=new ren();
            }

ren(){

article ar=new article();
ar.makedata();
articlenumber=ar.articlenumber;
article=ar.article;

System.out.println(articlenumber);

for(page=1;page<articlenumber+1;page++){

title[page]=maketitle(article[page]);

bun=article[page];
String[] x=bun.split("</tr>");
xlong=x.length;

str="";
for(s=0;s<xlong;s++){
if(x[s].indexOf("脚本")>0)str=x[s];
}

makeactor(str);

makedir(str);

makewriter(str);

makepro(str);

makecp(str);

}

for(page=1;page<articlenumber+1;page++){
makerate(article[page]);
}

writefile();

}

void writefile(){

int s,sx;

try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter("data.txt")));

for(s=1;s<articlenumber;s++){
pw.print("<data>");
pw.print("<title>");
pw.print(title[s]);
pw.print("</title>");

for(sx=1;sx<cpnumber[s]+1;sx++){
pw.print("<cp>");
pw.print(cp[s][sx]);
pw.print("</cp>");
}
for(sx=1;sx<pronumber[s]+1;sx++){
pw.print("<p>");
pw.print(pro[s][sx]);
pw.print("</p>");
}
for(sx=1;sx<writenumber[s]+1;sx++){
pw.print("<writer>");
pw.print(writer[s][sx]);
pw.print("</writer>");
}

for(sx=1;sx<dirnumber[s]+1;sx++){
pw.print("<dir>");
pw.print(dir[s][sx]);
pw.print("</dir>");
}
for(sx=1;sx<actornumber[s]+1;sx++){
pw.print("<actor>");
pw.print(actor[s][sx]);
pw.print("</actor>");
}
for(sx=1;sx<ratenumber[s]+1;sx++){
pw.print("<rate>");
pw.print(rate[s][sx]);
pw.print("</rate>");
}


pw.println("</data>");
}
  
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }


}




void makerate(String str){

int ylong,h,s,sx;
String[] y=str.split("<tr>");
String[] credit=new String[1000];
int creditnumber;
int p1,p2;
String strx;
sx=0;
ylong=y.length;
for(s=0;s<ylong;s++){
h=0;
if(y[s].indexOf("td class=")>0)h=h+1;
if(y[s].indexOf("center")>0)h=h+1;
if(h==2)sx=sx+1;
if(h==2)credit[sx]=y[s];
}
creditnumber=sx;

for(s=1;s<creditnumber+1;s++){
strx=credit[s];
p1=strx.indexOf("center");
p1=strx.indexOf(">",p1);
p2=strx.indexOf("<",p1);
rate[page][s]=strx.substring(p1+1,p2);
p1=rate[page][s].indexOf("分");
p2=rate[page][s].length();
if(p1>0)rate[page][s]=rate[page][s].substring(p1+2,p2);
System.out.println(rate[page][s]);
}



ratenumber[page]=creditnumber;



}

String maketitle(String str){
int p1,p2;
String cr;
p1=str.indexOf("red");
p1=str.indexOf(">",p1);
p2=str.indexOf("<",p1);
cr=str.substring(p1+1,p2);
cr=cr.replace(" ","△");
cr=cr.replace(" ","△");
cr=cr.replace("△","");
return cr;
}


void makewriter(String str){

String strx;
int s;

String[] x1=str.split("脚本");
strx=x1[1];
String[] x2=strx.split("<br>");
strx=x2[0];

strx=strx.replace("etc","");
strx=strx.replace(":","");
strx=strx.replace(" ","△");
strx=strx.replace(" ","△");
strx=strx.replace("△","");

String[] x3=strx.split("、");

for(s=0;s<x3.length;s++){
writer[page][s+1]=x3[s];
}
writenumber[page]=x3.length;


}

void makepro(String str){

String strx;
int s;

String[] x1=str.split("P");
strx=x1[1];
String[] x2=strx.split("<br>");
strx=x2[0];

strx=strx.replace("etc","");
strx=strx.replace(":","");
strx=strx.replace(" ","△");
strx=strx.replace(" ","△");
strx=strx.replace("△","");

String[] x3=strx.split("、");

for(s=0;s<x3.length;s++){
pro[page][s+1]=x3[s];
}
pronumber[page]=x3.length;


}

void makecp(String str){

String strx;
int s;

String[] x1=str.split("チーフP");
strx="空白";
if(x1.length>1)strx=x1[1];
String[] x2=strx.split("<br>");
strx=x2[0];

strx=strx.replace("etc","");
strx=strx.replace(":","");
strx=strx.replace(" ","△");
strx=strx.replace(" ","△");
strx=strx.replace("△","");

String[] x3=strx.split("、");

for(s=0;s<x3.length;s++){
cp[page][s+1]=x3[s];
}
cpnumber[page]=x3.length;
if(strx.equals("空白"))cpnumber[page]=0;

}



void makedir(String str){

String strx;
int s;

String[] x1=str.split("演出");
strx=x1[1];
String[] x2=strx.split("<br>");
strx=x2[0];

strx=strx.replace("etc","");
strx=strx.replace(":","");
strx=strx.replace(" ","△");
strx=strx.replace(" ","△");
strx=strx.replace("△","");

String[] x3=strx.split("、");

for(s=0;s<x3.length;s++){
dir[page][s+1]=x3[s];
}
dirnumber[page]=x3.length;


}


void makeactor(String str){
int s,sx,p1,p2,p3;
String strx;

p1=str.indexOf("rowspan");
p1=str.indexOf(">",p1);
p2=str.indexOf("脚本",p1);
p3=str.indexOf("原作",p1);
if(p3<0)p3=100000;
if(p3<p2)p2=p3;
strx=str.substring(p1+1,p2);
strx=strx.replace("<br>","");
strx=strx.replace("etc","");

String[] x4=strx.split("、");

sx=0;
for(s=0;s<x4.length;s++){
strx=x4[s];
strx=strx.replace(" ","△");
strx=strx.replace(" ","△");
strx=strx.replace("△","");
sx=sx+1;
actor[page][sx]=strx;
}
actornumber[page]=sx;

}



}
最終更新:2011年07月16日 15:23