package d3;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import tool.*;
public class pro {
int s,datanumber;
String[] data=new String[400000];
String[] name=new String[400000];
String[] code=new String[400000];
String[] codex=new String[40000];
int delta;
public static void main(String[] args) {
pro r=new pro();
}
pro(){
readx("x.csv");
delta=datanumber;
for(s=2;s<delta+1;s++){
String[] x=data[s].split(",");
name[s-1]="";
if(x.length>0)name[s-1]=x[0];
code[s-1]="";
if(x.length>1)code[s-1]=x[1];
}
int tr;
for(tr=1;tr<delta;tr++){
String word=name[tr]+" "+"オリコン芸能人事典";
makeutf sub6=new makeutf();
String d=sub6.makedata(word);
String urlx="https://www.bing.com/search?q=";
urlx=urlx+d;
if(code[tr].length()<1){
getdata sub7=new getdata();
sub7.makedata(urlx,"UTF-8");
data=sub7.data;
datanumber=sub7.datanumber;
String ss="aria-label=\"検索結果";
String str="";
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf(ss)>-1)str=data[s];
}
String[] x=str.split(">");
String d2="http://www.oricon.co.jp/prof/";
String pp="";
for(s=0;s<x.length;s++){
int h=0;
if(x[s].indexOf(d2)>-1)h=h+1;
if(pp.length()==0)h=h+1;
if(h==2)pp=x[s];
}
int p1=pp.indexOf("prof/");
int p2=-1;
if(p1>-1)p2=pp.indexOf("\"",p1);
if(p2>-1)pp=pp.substring(p1,p2);
code[tr]=pp;
}
System.out.println(name[tr]+","+code[tr]);
}
}
void readx(String file){
String str;
BufferedReader br;
int s;
s=0;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8"));
while((str = br.readLine()) != null) {
s=s+1;
data[s]=str;
}
br.close();
} catch (IOException e) {System.out.println(e);}
datanumber=s;
}
}
最終更新:2016年08月12日 00:32