アットウィキロゴ

p0000

package neko;
 
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import tool.*;
 
public class Neko {
 
     int s,datanumber;
String[] data=new String[5000];
String[] name=new String[5000];
String[] code=new String[5000];
String[] credit=new String[5000];
 
int number;
String str="";    
 
    public static void main(String[] args) {
        Neko y=new Neko();
    }
    Neko(){
 
        int tr;
 
     for(tr=1;tr<3575;tr++){   
        readfile sub4=new readfile();
        sub4.makedata("data/"+tr+".txt","UTF-8");
        data=sub4.data;
        datanumber=sub4.datanumber; 
 
        String str="";
        for(s=1;s<datanumber+1;s++){
      str=str+data[s];
 
        }
 
        str=str.replace("<table","</tr><");
 
        String[] x=str.split("</tr>");
        String a="show_p.php?num_p=";
 
        String[] link=new String[600];
        int sx=0;
        for(s=0;s<x.length;s++){
        if(x[s].indexOf(a)>-1)sx=sx+1;
         if(x[s].indexOf(a)>-1)link[sx]=x[s];
 
        }
 
     for(s=1;s<sx+1;s++){   
         link[s]=link[s].replace("</td>","△");
    String[] y=link[s].split("△");
     name[s]=y[1];
     credit[s]=change(y[0]);
     }
 
      for(s=2;s<sx+1;s++){   
    if(credit[s].length()<1)credit[s]=credit[s-1];   
      }
 
 
         for(s=1;s<sx+1;s++){   
 
 
    int p1=name[s].indexOf(a);
    p1=name[s].indexOf("=",p1);
    int p2=name[s].indexOf(">",p1);
    code[s]=name[s].substring(p1+1,p2-1); 
      }
 
      for(s=1;s<sx+1;s++){   
 
 
    int p1=name[s].indexOf(a);
    p1=name[s].indexOf(">",p1);
 
    int p2=name[s].indexOf("<",p1);
    if(p2>-1)name[s]=name[s].substring(p1+1,p2); 
 
      }
 
      number=sx;
 
      writexml("gdata/"+tr+".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.println(credit[s]+","+name[s]+","+code[s]); 
}
 
 
 
 
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=-1;
        if(p1>-1)p2=str.indexOf(">",p1);
        String strx="";
        if(p2>-1)strx=str.substring(p1,p2+1);
        str=str.replace(strx,"");
 
        return str;
    }    
 
}
 
最終更新:2016年08月20日 23:49