アットウィキロゴ

++LKJHGFDSA

import java.io.*;

class pro implements Runnable{

String data,urlx,z,key,file;
int[] x=new int[10000];
int[] y=new int[10000];
int[] tsecode=new int[2000];
String[] xml=new String[10000];
int s,xmlnumber;
int n,h;
int code;
String date,content,title;
String[] xdate=new String[10000];
String[] xtitle=new String[10000];
String[] xcontent=new String[10000];

String dx1,dn;
int datanumber;

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

pro(){

getcode gc=new getcode();
gc.makedata();
tsecode=gc.tsecode;

code=tsecode[950];

urlx="http://messages.yahoo.co.jp/bbs?action=q&board=";
urlx=urlx+code;

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

xymaker(data);

xmlmaker(data);

key=catchkey();

urlx=yahoo(code,1,key);

gt.makedata(urlx);
data=gt.data;

makedata(data);

String[] dx=date.split("No.1 /");
dx1=dx[1];
dx1=dx1.replace("]","A");
String[] dy=dx1.split("A");
dn=dy[0];
dn=dn.trim();
datanumber=Integer.parseInt(dn);
System.out.println(datanumber);


Thread th=new Thread(this);
th.start();

}

public void run(){
int t;
t=0;

while(t<datanumber+1){
t=t+1;
urlx=yahoo(code,t,key);

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

makedata(data);

xtitle[t]=title;
xdate[t]=date;
xcontent[t]=content;

System.out.println(date);

try{
Thread.sleep(50);
}catch(InterruptedException e){}
}

file="data/";
file=file+code;
file=file+".txt";

makefile(file);

}

String catchkey(){
int s,h,p3,p4;
String key,z,str1,str2,str3,str4;

str1="bbs";
str2="action=m";

z="";

for(s=1;s<xmlnumber-10;s++){
h=0;
if(xml[s].indexOf(str1)>0)h=h+1;
if(xml[s].indexOf(str2)>0)h=h+1;
if(h==2)z=xml[s];
}

str3="tid=";
str4="&sid";

p3=z.indexOf(str3);
p4=z.indexOf(str4);

key=z.substring(p3,p4);

return key;
}


String yahoo(int code,int num,String key){
int ycode;
String urlx;

ycode=1000000+code;

urlx="http://messages.yahoo.co.jp/bbs?.mm=FN&action=m&board=";
urlx=urlx+ycode;
urlx=urlx+"&";
urlx=urlx+key;
urlx=urlx+"&sid=";
urlx=urlx+ycode;
urlx=urlx+"&mid=";
urlx=urlx+num;

return urlx;
}




void xmlmaker(String str){
int s,p1,p2;

for(s=1;s<xmlnumber-10;s++){
p1=x[s];
p2=y[s];
xml[s]=str.substring(p1+1,p2);
}

}
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 makedata(String data){

int sx,h,p1,p2;
String bun,z1,z2;
String str1,str2;
String[] z=new String[100];

title="";
date="";
content="";

str1="<!--// MESSAGE -->";
str2="<!--// /MESSAGE -->";

p1=data.indexOf(str1);
p2=data.indexOf(str2);

h=0;
if(p1<1)h=100;
if(p2<1)h=100;

while(h<50){

bun=data.substring(p1,p2);

xymaker(bun);

z2="";
for(s=1;s<xmlnumber-1;s++){
p1=y[s];
p2=x[s+1];
z1=bun.substring(p1+1,p2);
if(z1.length()>0)z2=z1;
}

content=z2;

str1="<!--// MAIN TOPIC -->";
str2="<!--// USER -->";

p1=data.indexOf(str1);
p2=data.indexOf(str2);

bun=data.substring(p1,p2);

xymaker(bun);

z2="";
sx=0;
for(s=1;s<xmlnumber-1;s++){
p1=y[s];
p2=x[s+1];
z1=bun.substring(p1+1,p2);
if(z1.length()>0)sx=sx+1;
if(z1.length()>0)z[sx]=z1;
}

title=z[1];
date=z[2];

h=100;

}


}


void makefile(String file){

int t,h;

try{
PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter(file)));

for (t=1;t<datanumber+1;t++){  
h=0;
if(xdate[t].length()>0)h=100;
if(h>50)pw.print("<");
if(h>50)pw.print(xtitle[t]);    
if(h>50)pw.print(">");  
if(h>50)pw.print("<");
if(h>50)pw.print(xcontent[t]);    
if(h>50)pw.print(">");
if(h>50)pw.print("<");
if(h>50)pw.print(xdate[t]);    
if(h>50)pw.println(">");
}
System.out.println("ファイルに書きこみました。");
pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }


}


}
最終更新:2011年04月18日 23:25