アットウィキロゴ

週銀

import java.io.*;

class ch{

String urlx,data,file,str;
int[] x=new int[5000];
int[] y=new int[5000];
String[] credit=new String[5000];
String[] link=new String[5000];
String[] lk=new String[50000];
String[] ur=new String[5000];
int linknumber,number;
int s,sx,xmlnumber,h;
int no,np,t,p1,p2;

public static void main(String [] args) {
        ch test=new ch();
            }

ch(){

np=0;
for(no=1;no<177;no++){

urlx="http://kokkai.ndl.go.jp/SENTAKU/syugiin/";
if(no<10)urlx=urlx+0;
if(no<100)urlx=urlx+0;
urlx=urlx+no;
urlx=urlx+"/mainb.html";

getdata g=new getdata();
g.makedata(urlx);
data=g.data;

xymaker(data);

sx=0;
for(s=1;s<xmlnumber+1;s++){
str=creditmaker(s,data);
h=0;
if(str.indexOf("href")>1)h=h+1;
if(str.indexOf("TARGET")>1)h=h+1;
if(h==2)sx=sx+1;
if(h==2)credit[sx]=str;
}

linknumber=sx;
for(s=1;s<linknumber+1;s++){
p1=credit[s].indexOf("./");
p2=credit[s].indexOf("main");
link[s]=credit[s].substring(p1+1,p2);
}


for(t=1;t<linknumber+1;t++){
urlx="http://kokkai.ndl.go.jp/SENTAKU/syugiin/";
if(no<10)urlx=urlx+0;
if(no<100)urlx=urlx+0;
urlx=urlx+no;
urlx=urlx+link[t];
urlx=urlx+"mainb.html";
ur[t]=urlx;
}

for(t=1;t<linknumber+1;t++){
np=np+1;
lk[np]=ur[t];
}


}

number=np;

writefile();

}


void writefile(){

try{
PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter("ren.txt")));

for(t=1;t<number+1;t++){                                              
pw.println(lk[t]);                                                                
}

System.out.println("ファイルに書きこみました。");
pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }

}




String creditmaker(int s,String str){
int p1,p2;
String bara;
p1=x[s];
p2=y[s];
bara=str.substring(p1+1,p2);
return bara;
}


void xymaker(String str){
int p1;
int s;
s=1;
p1=str.indexOf("<");
x[1]=p1;
while(p1>-1){
p1=str.indexOf("<",p1+1);
if(p1>-1)s=s+1;
if(p1>-1)x[s]=p1;
}
xmlnumber=s;
for(s=1;s<xmlnumber+1;s++){
y[s]=str.indexOf(">",x[s]);
}

}


}
最終更新:2011年06月26日 09:02