アットウィキロゴ

cpcp

package anime;
 
import java.io.*;
import tool.*;
 
public class pro {
 
    int s,datanumber;
    String[] data=new String[5000];
    int[] point=new int[5000];
      String[] artist=new String[5000];
 String[] t=new String[5000];
      int[] year=new int[5000];
 int[] month=new int[5000];
 int[] day=new int[5000];
 int[] rank=new int[5000];
 
 String[] date=new String[5000];
  String[] title=new String[5000];
 String[] v1=new String[5000];
  String[] v2=new String[5000];
  String[] box=new String[5000];
   String[] season=new String[5000];
   int number;
   int yy;
 
    public static void main(String[] args) {
        pro test=new pro();
    }
 
    pro(){
 
     for(yy=2000;yy<2015;yy++){
 
        String urlx="http://dvdbd.wiki.fc2.com/wiki/"+yy+"%E5%B9%B4%E3%81%AE%E3%82%A2%E3%83%8B%E3%83%A1";
 
 
  getdata sub2=new getdata();
   sub2.makedata(urlx,"UTF-8");
   data=sub2.data;
   datanumber=sub2.datanumber;
        int sx=0;
   for(s=1;s<datanumber+1;s++){
      if(data[s].indexOf("<table")>-1)sx=sx+1; 
   if(data[s].indexOf("<table")>-1)month[sx]=s;   
   }
 
 
   sx=0;
   for(s=1;s<datanumber+1;s++){
      if(data[s].indexOf("</table")>-1)sx=sx+1; 
   if(data[s].indexOf("</table")>-1)day[sx]=s;
 
   }
 
   for(s=1;s<6;s++){
   String str="";
   for(sx=month[s];sx<day[s];sx++){
   str=str+data[sx];    
   }    
   t[s]=str;
   }
 
   int tx,p;
   p=0;
   for(s=1;s<6;s++){
   String[] x=t[s].split("</tr>");
   String k="冬";
   if(s==2)k="春";
    if(s==3)k="夏";
     if(s==4)k="秋";
   if(s==5)k="その他";
   for(sx=1;sx<x.length;sx++){
   p=p+1;
   season[p]=k;
   String[] y=x[sx].split("</td>");
   for(tx=0;tx<y.length;tx++){
   if(tx==0)box[p]=y[tx];
   if(tx==1)v1[p]=y[tx];
   if(tx==2)v2[p]=y[tx];
   if(tx==3)title[p]=y[tx];
   if(tx==4)date[p]=y[tx];
   }
   }
   }
 
 
   number=p;
   for(s=1;s<number+1;s++){
   title[s]=change(title[s]);
   v1[s]=change(v1[s]);
   v2[s]=change(v2[s]);
   date[s]=change(date[s]);
   }
 
 
 
   writexml("data/"+yy+".txt");
    }
 
 
    }
 
      void writexml(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
for(s=1;s<number+1;s++){   
pw.print("<year>"); 
pw.print(yy); 
pw.print("</year>"); 
pw.print("<sesson>"); 
pw.print(season[s]); 
pw.print("</season>"); 
pw.print("<date>"); 
pw.print(date[s]); 
pw.print("</date>"); 
pw.print("<title>");
pw.print(title[s]);
pw.print("</title>"); 
pw.print("<avg>");
pw.print(v1[s]);
pw.print("</avg>"); 
pw.print("<box>");
pw.print(v2[s]); 
pw.println("</box>");
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
 
    String change(String str){
 
        int n;
        for(n=1;n<11;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年03月01日 18:54