アットウィキロゴ

dl srt

package drama;
 
import tool.*;
import java.io.*;
 
public class pro {
 
    int s,datanumber;
    String[] data=new String[5000];
     String[] subdata=new String[500000];
   String[] artist=new String[5000];
int number;
 
 
    public static void main(String[] args) {
        pro t=new pro();
    }
 
    pro(){
 
   readfile sub2=new readfile();
   sub2.makedata("data.csv","UTF-8");
   data=sub2.data;
   datanumber=sub2.datanumber;
 
   int tr;
   int k=0;
   for(tr=2;tr<datanumber+1;tr++){
 
   String[] x=data[tr].split(",");
 
    String t=x[0];
    String c=x[1];
 
        artist sub=new artist();
        sub.makedata(c);
        artist=sub.artist;
        number=sub.number;
 
        for(s=1;s<number+1;s++){
        k=k+1;
            subdata[k]=t+","+c+","+artist[s];    
        }
 
 
   }
 
   number=k;
 
writexml("ren.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(subdata[s]);   
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
 
}
 
 
package drama;
 
 
import tool.*;
import java.io.*;
 
public class artist {
 
    int s,datanumber;
    String[] data=new String[5000];
     String[] credit=new String[5000];
   String[] artist=new String[5000];
int number;
 
 
 
 
    void makedata(String code){
 
        String urlx="http://www.tvdrama-db.com/drama_info/p/id-"+code;
 
 
   getdata sub=new getdata();
   sub.makedata(urlx,"UTF-8");
   data=sub.data;
   datanumber=sub.datanumber;
 
 String str="";
   for(s=1;s<datanumber+1;s++){
   str=str+data[s];
 
   }
 
 
   String[] x=str.split("</tr>");
 
 
   String strx="";
   for(s=2;s<x.length-1;s++){
     String[] x1=x[s].split("</td>");
     x1[0]=clean_str(x1[0]);
     credit[s]=x1[0].trim();
 
     if(credit[s].indexOf("出演")>-1)strx=x1[1];
 
   } 
 
 
   int sx=0;
 
   String[] u=strx.split("、");
for(s=0;s<u.length;s++){     
   u[s]=clean_str(u[s]);
   int p1=u[s].indexOf("(");
   if(p1>0)u[s]=u[s].substring(0,p1);
   p1=u[s].indexOf("(");
   if(p1>0)u[s]=u[s].substring(0,p1);
   p1=u[s].indexOf(")");
   if(p1>0)u[s]=u[s].substring(p1+1,u[s].length());
   u[s]=u[s].trim();
    u[s]=u[s].replace(" ","");
     u[s]=u[s].replace("(以下","");
    if(u[s].length()>0)sx=sx+1;
      if(u[s].length()>0)artist[sx]=u[s];
 
    }
number=sx;   
 
 
 
 
 
 
 
    }
 
 
 
 
 
String clean_str(String str){
 
    int m;
  String strx=str;
  for(m=1;m<15;m++){
  strx=fresh(strx);
  }
 
  strx=strx.replace("&nbsp","");
  strx=strx.replace("&nbsp","");
  strx=strx.replace(";","");
  return strx;
 
}
 
String fresh(String str){
 
  int p1=str.indexOf("<");
  int p2=str.indexOf(">",p1);
  String sp="";
  if(p1>-1)sp=str.substring(p1,p2+1);
 
  String k=str.replace(sp,"");
  return k;
}
 
 
}
 
最終更新:2017年06月03日 13:03