アットウィキロゴ

DLの練習

package music;
 
 
import tool.*;
import java.io.*;
 
public class pro {
 
    int s,datanumber;
    String[] data=new String[5000];
    String urlx;
   String[] artist=new String[5000];
     String[] link=new String[5000];
int week,month;
 
 String[][] subdata=new String[500][20];
 int number;
 
    public static void main(String[] args) {
        pro test=new pro();
    }
 
   pro(){
 
 
       int m,w;
 
 
 
 
 
 
 
 
       link[1]="http://www.oricon.co.jp/rank/js/w/2016-06-13/p/2/";
 
       int tr;
 
       for(tr=1;tr<2;tr++){
 
           getdata sub=new getdata();
    sub.makedata(link[tr],"SJIS");
        data=sub.data;
        datanumber=sub.datanumber;
 
        int s1=0;
        for(s=1;s<datanumber+1;s++){
if(data[s].indexOf("<div class=\"content-rank-main\">")>-1)s1=s; 
 
        }
 
 
        int s2=0;
          for(s=s1+1;s<datanumber+1;s++){
if(data[s].indexOf("content-rank-main")>-1)s2=s;
 
        }
 
 
          String str="";
       for(s=s1;s<s2+1;s++){
       str=str+data[s];
 
       }
 
       int sx;
       for(s=0;s<101;s++){
       for(sx=0;sx<15;sx++){
       subdata[s][sx]="";
       }
       }
 
 
 
       String[] x=str.split("</ul>");
       for(s=0;s<x.length;s++){
         str=x[s].replace("	","");
       str=str.replace("</p>","</li>");
         String[] y=str.split("</li>");
 
      for(sx=0;sx<y.length;sx++){ 
       y[sx]=y[sx].replace("</h2>","○");
       subdata[s][sx]=change(y[sx]); 
       }
       }
 
 
       number=x.length;
 
       System.out.println(number);
 
 
 
 
       }
 
 
 writexml("ren.txt");
 
 
 
 
} 
 
 
 
    void writexml(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
for(s=0;s<number;s++){   
for(sx=0;sx<12;sx++){ 
pw.print(s); 
pw.print(","); 
pw.print(sx); 
pw.print(","); 
pw.println(subdata[s][sx]);  
}
} 
 
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年06月13日 03:00