import java.io.*;
class pro{
int[] x=new int[100];
int[] y=new int[100];
int xmlnumber;
String urlx,file,bun;
String[] data=new String[50000];
String[] article=new String[1500];
int [] index=new int[1500];
int datanumber,s,sx;
int p1,s1,s2,s3,h;
int articlenumber;
int n,n1,n2;
public static void main(String [] args) {
pro test=new pro();
}
pro(){
urlx="http://logsoku.com/thread/hato.2ch.net/akb/1309789026/";
getdata g=new getdata();
g.makedata(urlx);
data=g.data;
datanumber=g.datanumber;
s1=0;
s2=0;
for(s=1;s<datanumber+1;s++){
p1=data[s].indexOf("スレッド表示");
h=0;
if(p1>0)h=h+1;
if(s1<1)h=h+1;
if(h==2)s1=s;
h=0;
if(p1>0)h=h+1;
if(s1>0)h=h+1;
if(h==2)s2=s;
}
s3=0;
for(s=s1;s<s2;s++){
p1=data[s].indexOf("float:left;font-size:12px");
h=0;
if(p1>0)h=h+1;
if(s3<1)h=h+1;
if(h==2)s3=s;
}
sx=0;
for(s=s1+1;s<s3;s++){
p1=data[s].indexOf("<dt>");
if(p1>-1)sx=sx+1;
if(p1>-1)index[sx]=s;
}
articlenumber=sx;
System.out.println(articlenumber);
for(s=1;s<articlenumber;s++){
n1=index[s];
n2=index[s+1];
bun=data[n1];
for(n=n1+1;n<n2;n++){
bun=bun+data[n];
}
String[] x=bun.split("<dd>");
article[s]=x[1];
}
file="ren.txt";
writefile(file);
}
String credit(){
int s;
String cr;
cr=bun.substring(0,x[1]);
for(s=1;s<xmlnumber;s++){
if(x[s+1]>y[s])cr=cr+bun.substring(y[s]+1,x[s+1]);
}
s=xmlnumber;
cr=cr+bun.substring(y[s]+1,bun.length());
return cr;
}
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]);
}
}
void writefile(String file){
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
for(s=1;s<articlenumber;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;
}
}
最終更新:2011年07月11日 13:24