package sjis;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import tool.*;
import java.util.HashMap;
public class pro {
int s,datanumber;
String[] data=new String[5000];
String[] subdata=new String[5000];
String[] memo=new String[5000];
HashMap<String,String> map = new HashMap<String,String>();
String[] name=new String[8000];
String[] gid=new String[8000];
int delta;
public static void main(String[] args) {
pro t=new pro();
}
pro(){
readfile sub7=new readfile();
sub7.makedata("SJIS.csv","UTF-8");
data=sub7.data;
datanumber=sub7.datanumber;
for(s=2;s<datanumber+1;s++){
String[] x=data[s].split(",");
String str="%"+x[2]+"%"+x[1];
map.put(x[0],str);
}
readfile sub8=new readfile();
sub8.makedata("w.csv","UTF-8");
data=sub8.data;
datanumber=sub8.datanumber;
for(s=2;s<datanumber+1;s++){
String[] x=data[s].split(",");
name[s-1]="";
if(x.length>3)name[s-1]=x[3];
}
delta=datanumber-1;
int tr=1;
for(tr=1;tr<delta;tr++){
String w=makeword(name[tr]);
String urlx="http://www.oricon.co.jp/search/result.php?types=artist&search_string="+w+"&x=0&y=0";
try{
getdata sub6=new getdata();
sub6.makedata(urlx,"SJIS");
data=sub6.data;
datanumber=sub6.datanumber;
Thread.sleep(100);
}catch(InterruptedException e){}
int sx=0;
for(s=1;s<datanumber+1;s++){
int h=0;
if(data[s].indexOf("/prof/")>-1)h=h+1;
if(data[s].indexOf("ランキング")<1)h=h+1;
if(h==2) sx=sx+1;
if(h==2)memo[sx]=data[s];
}
for(s=1;s<sx+1;s++){
int p1=memo[s].indexOf("/prof/");
int p2=memo[s].indexOf("\"",p1);
memo[s]=memo[s].substring(p1,p2);
}
gid[tr]="";
if(sx>0)gid[tr]=memo[1];
System.out.println(name[tr]+","+gid[tr]);
}
writexml("ren.txt");
}
void writexml(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
for(s=1;s<delta+1;s++){
pw.print(name[s]);
pw.print(",");
pw.println(gid[s]);
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
String search(String ch){
String w1="";
if(map.containsKey(ch))w1=map.get(ch);
return w1;
}
String makeword(String ww){
int s;
String k="";
for(s=0;s<ww.length();s++){
String d1=ww.substring(s,s+1);
k=k+search(d1);
}
return k;
}
}
最終更新:2016年08月11日 03:51