アットウィキロゴ

drama

package drama;
 
import tool.*;
import java.io.*;
 
public class pro {
 
    int s,datanumber;
    String[] data=new String[5000];
     String[] credit=new String[5000];
   String[] artist=new String[5000];
int number;
 
 
    public static void main(String[] args) {
        pro t=new pro();
    }
 
    pro(){
 
        String urlx="http://www.tvdrama-db.com/drama_info/p/id-57898";
 
 
   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;   
 
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(artist[s]);   
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
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月02日 18:27