package base;
import tool.*;
import java.io.*;
public class pro {
int s,datanumber;
String[] data=new String[5000];
String[] subdata=new String[5000];
int[] a=new int[210];
int[] b=new int[210];
int number;
String[] link=new String[5000];
String[] t=new String[5000];
String[] team=new String[5000];
String[] name=new String[5000];
String[] rank=new String[5000];
String[] pos=new String[5000];
String[] school=new String[5000];
public static void main(String[] args) {
pro t=new pro();
}
pro(){
int p;
for(p=1;p<52;p++){
readfile sub2=new readfile();
sub2.makedata("data/"+p+".txt","UTF-8");
data=sub2.data;
datanumber=sub2.datanumber;
int sx=0;
for(s=1;s<datanumber+1;s++){
int p1=data[s].indexOf("<span");
p1=data[s].indexOf(">",p1);
int p2=data[s].indexOf("<",p1);
team[s]=data[s].substring(p1+1,p2);
}
int num=0;
int tr=8;
for(tr=1;tr<datanumber+1;tr++){
data[tr]=data[tr].replace("th","td");
String[] x=data[tr].split("</tr>");
for(s=1;s<x.length;s++){
String[] y=x[s].split("</td>");
rank[s]="";
name[s]="";
pos[s]="";
school[s]="";
for(sx=0;sx<y.length;sx++){
if(sx==0)rank[s]=change(y[sx]);
if(sx==1)name[s]=y[sx];
if(sx==2)pos[s]=change(y[sx]);
if(sx==3)school[s]=change(y[sx]);
}
}
for(s=1;s<x.length;s++){
int p1=name[s].indexOf("/wiki");
int p2=name[s].indexOf("\"",p1);
link[s]="";
if(p1>-1)link[s]=name[s].substring(p1+1,p2);
}
for(s=1;s<x.length;s++){
int p1=name[s].indexOf("title=");
p1=name[s].indexOf(">",p1);
int p2=-1;
if(p1>-1) p2=name[s].indexOf("<",p1);
if(p2>-1)name[s]=name[s].substring(p1+1,p2);
if(p2>-1)name[s]=change(name[s]);
}
for(s=1;s<x.length;s++){
if(name[s].length()>0)num=num+1;
if(name[s].length()>0)subdata[num]=team[tr]+","+rank[s]+","+name[s]+","+pos[s]+","+school[s]+","+link[s];
}
}
datanumber=num;
writexml("gdata/"+p+".txt");
}
}
void writexml(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
for(s=1;s<datanumber+1;s++){
pw.println(subdata[s]);
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
String change(String str){
int n;
for(n=1;n<25;n++){
str=rev(str);
}
str=str.replace(" ","");
return str;
}
String rev(String str){
if(str==null)str="";
int p1=str.indexOf("<");
int p2=str.indexOf(">",p1);
String strx="";
if(p2>-1)strx=str.substring(p1,p2+1);
str=str.replace(strx,"");
return str;
}
}
最終更新:2016年12月14日 02:48