アットウィキロゴ

prpr

package pr;
 
 
public class pro {
 
 
    public static void main(String[] args) {
        pro t=new pro();
    }
    pro(){
 
 
        age sub=new age();
        sub.makedata("247661");
 
 
    }
 
 
}
 
 
package pr;
 
import tool.getdata;
 import java.io.*;
 
public class age {
 
     int s,datanumber;
    String[] data=new String[6000];
   String[] credit=new String[6000];
      String[] name=new String[6000];
   int number;
 
   void makedata(String gid){
 
 
           String urlx="http://www.oricon.co.jp/prof/";
           urlx=urlx+gid+"/profile/";
 
 
        getdata sub7=new getdata();
        sub7.makedata(urlx,"SJIS");
        data=sub7.data;
        datanumber=sub7.datanumber; 
 
       int s1=0;
     for(s=1;s<datanumber+1;s++){
     if(data[s].indexOf("<div class=\"box-artist\">")>-1)s1=s;
     }
 
     int s2=s1;
     for(s=s1+1;s<datanumber+1;s++){
     if(data[s].indexOf("<!--/.box-artist-profile-->")>-1)s2=s;
     }
 
     String str="";           
    for(s=s1;s<s2;s++){
    str=str+data[s];
 
    }
 
    String[] x=str.split("</tr>");
    int sx=0;
    for(s=0;s<x.length-1;s++){
    sx=sx+1;
        int p1=x[s].indexOf("<td");
    int p2=x[s].indexOf("</td",p1);
    String strx="";
    if(p1>-1)strx=x[s].substring(p1,p2);
   name[sx]= change(strx);  
    p1=x[s].indexOf("<th");
    p2=x[s].indexOf("</th",p1);
    strx="";
    if(p1>-1)strx=x[s].substring(p1,p2);
    credit[sx]=change(strx);
    }
 
   number=sx;
 
 
   writexml("data/"+gid+".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.print(credit[s]); 
     pw.print(",");
    pw.println(name[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=str.indexOf(">",p1);
        String strx="";
        if(p2>-1)strx=str.substring(p1,p2+1);
        str=str.replace(strx,"");
 
        return str;
    }    
 
 
 
}
 
最終更新:2016年08月26日 11:40