package kadokawa;
import java.io.*;
import java.io.FileWriter;
import java.io.PrintWriter;
import tool.*;
public class pro {
int s,datanumber;
String[] data=new String[50000];
String[] name=new String[50000];
String[] id=new String[50000];
int[] year=new int[50000];
int[] month=new int[50000];
int[] day=new int[50000];
String[] th=new String[50000];
String[] v1=new String[50000];
String[] v2=new String[50000];
String[] v3=new String[50000];
String[] time=new String[50000];
String[] gid=new String[50000];
public static void main(String[] args) {
pro te=new pro();
}
pro(){
readfile sub=new readfile();
sub.makedata("ren.txt","UTF-8");
data=sub.data;
datanumber=sub.datanumber;
for(s=1;s<datanumber+1;s++){
String[] x=data[s].split("△");
name[s]=x[6];
String dd=x[1];
String k=dd.substring(0,4);
year[s]=numx(k);
k=dd.substring(4,6);
month[s]=numx(k);
k=dd.substring(6,8);
day[s]=numx(k);
th[s]=x[0];
v1[s]=x[3];
v2[s]=x[4];
v3[s]=x[5];
time[s]=x[2].trim();
}
int dicnumber=0;
String[] dic=new String[50000];
int sx;
for(s=1;s<datanumber+1;s++){
int h=0;
for(sx=1;sx<dicnumber+1;sx++){
if(name[s].equals(dic[sx]))h=100;
}
if(h<50)dicnumber=dicnumber+1;
if(h<50)dic[dicnumber]=name[s];
}
for(s=1;s<dicnumber+1;s++){
int p1=dic[s].indexOf("(");
String str=dic[s];
if(p1>0)str=dic[s].substring(0,p1);
p1=dic[s].indexOf("[");
str=str;
if(p1>-1)str=dic[s].substring(0,p1);
id[s]=search(str);
System.out.println(dic[s]+","+id[s]);
}
for(s=1;s<datanumber+1;s++){
gid[s]="";
for(sx=1;sx<dicnumber+1;sx++){
if(name[s].equals(dic[sx]))gid[s]=id[sx];
}
}
writexml("data.csv");
}
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(year[s]+","+month[s]+","+day[s]+","+time[s]+","+th[s]+","+name[s]+","+v1[s]+","+v2[s]+","+v3[s]+","+gid[s]);
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
String search(String word){
String[] name=new String[5000];
String[] id=new String[5000];
makeutf sub6=new makeutf();
String d=sub6.makedata(word);
int datanumber;
String urlx="http://movie.walkerplus.com/search/free_search.cgi?comkind=movie&keyword="+d;
getdata sub7=new getdata();
sub7.makedata(urlx,"UTF-8");
data=sub7.data;
datanumber=sub7.datanumber;
int s;
int sx=0;
for(s=1;s<datanumber+1;s++){
int h=0;
if(data[s].indexOf("com/mv")>-1)h=h+1;
if(data[s].indexOf("</h5>")>-1)h=h+1;
if(h==2) sx=sx+1;
if(h==2)name[sx]=data[s];
}
int number=sx;
for(s=1;s<number+1;s++){
int p1=name[s].indexOf("mv");
int p2=name[s].indexOf("/",p1);
id[s]=name[s].substring(p1,p2);
p1=name[s].indexOf(">",p1);
p2=name[s].indexOf("<",p1+1);
name[s]=name[s].substring(p1+1,p2);
}
String w1="";
if(number>0)w1=id[1];
return w1;
}
int numx(String str){
int nx;
nx=0;
try{
nx=Integer.parseInt(str);
}catch (Exception e) {}
return nx;
}
}
最終更新:2016年08月01日 17:08