アットウィキロゴ

ブログ解析XX

import java.io.*;

class game{

int[] x=new int[10000];
int[] y=new int[10000];
int xmlnumber,linknumber;
String data[]=new String[100];    
String link[]=new String[100];
String article[]=new String[100];  
int s,datanumber;
String urlx;
String bun,str,str1,str2;
int page,s1,s2;

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

game(){

readfile("link.txt");

linknumber=datanumber;

for(s=1;s<datanumber+1;s++){
link[s]=data[s];
}

for(page=1;page<linknumber+1;page++){

urlx=link[page];

getdata gt=new getdata();
gt.makedata(urlx);
data=gt.data;
datanumber=gt.datanumber;

str1="google_ad_section_start";
str2="google_ad_section_end";

s1=0;
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf(str1)>0)s1=s;;
}
s2=0;
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf(str2)>0)s2=s;;
}

str=data[s1+1];
for(s=s1+2;s<s2;s++){
str=str+data[s];
}

xymaker(str);

if(x[2]>y[1])bun=str.substring(y[1]+1,x[2]);
for(s=2;s<xmlnumber;s++){
if(x[s+1]>y[s])bun=bun+str.substring(y[s]+1,x[s+1]);
}

article[page]=bun;

}

writefile();

}

void writefile(){

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

for(s=1;s<linknumber;s++){
pw.println(article[s]);
}
  
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }


}


void readfile(String file){

String str;
BufferedReader br;  

s=0;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"SJIS"));  
while((str = br.readLine()) != null) {  
s=s+1;
data[s]=str;  
}
br.close();
} catch (IOException e) {System.out.println(e);}  

datanumber=s;

}

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年07月15日 04:14