import java.io.*;
class pro{
String urlx,data;
int[] x=new int[100000];
int[] y=new int[100000];
String[] credit=new String[10000];
String[] content=new String[10000];
String[] link=new String[10000];
String[] memo=new String[10000];
String web;
int p1,p2,p3,h;
int s,sx,xmlnumber,linknumber;
int page,d;
public static void main(String [] args) {
pro test=new pro();
}
pro(){
d=0;
for(page=1;page<10;page++){
urlx="http://cinema.pia.co.jp/imp/?page=";
urlx=urlx+page;
urlx=urlx+"&sort=0";
getdata gt=new getdata();
gt.makedata(urlx);
data=gt.data;
xymaker(data);
for(s=1;s<xmlnumber+1;s++){
credit[s]=data.substring(x[s],y[s]);
}
sx=0;
for(s=1;s<xmlnumber+1;s++){
p1=credit[s].indexOf("title");
p2=credit[s].indexOf("imp");
p3=credit[s].indexOf("page");
h=0;
if(p1>-1)h=h+1;
if(p2>-1)h=h+1;
if(p3>-1)h=0;
if(h==2)sx=sx+1;
if(h==2)link[sx]=credit[s];
}
linknumber=sx;
for(s=1;s<linknumber+1;s++){
p1=link[s].indexOf("href=");
p2=link[s].indexOf("title");
web=link[s].substring(p1+6,p2-2);
urlx="http://cinema.pia.co.jp";
urlx=urlx+web;
d=d+1;
memo[d]=urlx;
}
}
writefile("link.txt");
}
void writefile(String file){
try{
PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter(file)));
for(s=1;s<d+1;s++){
pw.println(memo[s]);
}
System.out.println("ファイルに書きこみました。");
pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
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月29日 23:09