import java.io.*;
class link{
int[] x=
new int[5000];
int[] y=new int[5000];
String[] credit=new String[5000];
String[] point=new String
[100];
String[] title=new String[100];
String[] author=new String[100];
String[] point2=new String[100000];
String[] title2=new String[100000];
String[] author2=new String[100000];
String
file;
String data,str,str1,str2;
int page,p1,p2,s;
int xmlnumber,articlenumber;
int sx,num,number;
int an,bn,cn;
public static void main(String [] args) {
link test=new link();
}
link(){
num=0;
for(page=2000;page<3000;page++){
file="data/";
file=file+page;
file=file+".
txt";
str1="<tbody>";
str2="</tbody>";
p1=data.indexOf(str1);
p2=data.indexOf(str2);
str=data.substring(p1,p2);
xymaker(str);
for(s=1;s<xmlnumber+1;s++){
credit[s]=str.substring(x[s],y[s]);
}
for(s=1;s<31;s++){
sx=4*(s-1)+2;
point[s]=credit[sx];
sx=4*(s-1)+3;
title[s]=credit[sx];
sx=4*(s-1)+4;
author[s]=credit[sx];
}
for(s=1;s<31;s++){
String[] x1=author[s].split("title=");
author[s]=x1[1];
author[s]=author[s].replace("</a>","");
String[] x2=author[s].split("/>");
author[s]=x2[1];
}
for(s=1;s<31;s++){
String[] x3=point[s].split("alt=");
point[s]=x3[1];
point[s]=point[s].replace("/>","");
p1=point[s].indexOf("点");
point[s]=point[s].substring(1,p1+1);
}
for(s=1;s<31;s++){
String[] x4=title[s].split("title=");
if(x4.length<2)title[s]="不明";
if(x4.length>1)title[s]=x4[1];
String[] x5=title[s].split(">");
if(x5.length<2)title[s]="不明";
if(x5.length>1)title[s]=x5[1];
title[s]=title[s].replace("</a","");
}
for(s=1;s<31;s++){
num=num+1;
point2[num]=point[s];
title2[num]=title[s];
author2[num]=author[s];
}
}
writefile();
}
void writefile(){
int s,sx;
try{
PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter("data3.txt")));
for(s=1;s<num+1;s++){
pw.
print("<");
pw.print(author2[s]);
pw.print(">");
pw.print("<");
pw.print(title2[s]);
pw.print(">");
pw.print("<");
pw.print(point2[s]);
pw.println(">");
}
System.out.println("
ファイルに書きこみました。");
pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
void xymaker(String str){
int p1;
int s;
s=1;
p1=str.indexOf("<td>");
x[1]=p1;
while(p1>-1){
p1=str.indexOf("<td>",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("</td>",x[s]);
}
}
void readfile(String file){
String str;
BufferedReader br;
data="";
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"SJIS"));
while != null) {
data=data+str;
}
br.close();
} catch (IOException e) {System.out.println(e);}
}
}
最終更新:2011年07月10日 04:13