package tv2;
import tool.*;
import java.io.*;
import java.io.File;
public class pro {
int s,datanumber;
String[] data=new String[5000];
String[] subdata=new String[5000];
String[] time=new String[5000];
String[] title=new String[5000];
String[] link=new String[5000];
int number;
public static void main(String[] args) {
pro te=new pro();
}
pro(){
File f=new File("data");
String[] ff=f.list();
int tr;
for(tr=0;tr<ff.length;tr++){
readfile sub=new readfile();
sub.makedata("data/"+ff[tr],"UTF-8");
data=sub.data;
datanumber=sub.datanumber;
String str1="<span class=\"min\">";
int sx=0;
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf(str1)>0)sx=sx+1;
if(data[s].indexOf(str1)>0)subdata[sx]=data[s];
}
number=sx;
for(s=1;s<number+1;s++){
int p1=subdata[s].indexOf(str1);
int p2=subdata[s].indexOf("</spa",p1+1);
time[s]=subdata[s].substring(p1,p2);
time[s]=time[s].replace(str1,"");
int p3=subdata[s].indexOf("</a",p2+1);
title[s]=subdata[s].substring(p2,p3);
title[s]=title[s].replace("</span>","");
title[s]=title[s].replace("<span class=\"episode\">","△");
int p4=subdata[s].indexOf("/program/");
int p5=subdata[s].indexOf("\"",p4);
link[s]=subdata[s].substring(p4,p5);
}
writexml("gdata/"+ff[tr]);
}
}
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(time[s]);
pw.print(",");
pw.print(title[s]);
pw.print(",");
pw.println(link[s]);
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
}
最終更新:2017年01月15日 06:22