アットウィキロゴ

ブログ処理

import java.io.*;
import java.net.*;

class game0320{

int s;
String str,urlx;
String bun,chbun;    
String[] article=new String[100];
String[] title=new String[100];
String[] des=new String[100];
int articlenumber;
String z;

public static void main(String [] args) {
        game0320 f=new game0320();
            }

game0320(){

urlx="http://35418646.at.webry.info/theme/db1d11aa09.rdf";

getdata(urlx);

chbun=cutrdf(bun);

makearticle(chbun);


for(s=1;s<articlenumber+1;s++){
title[s]=maketitle(article[s]);
des[s]=makedes(article[s]);
}

for(s=1;s<articlenumber+1;s++){
System.out.println(title[s]);
System.out.println(des[s]);
}




}

String cutrdf(String str){
String str1,z;
String[] y=new String[10];
int p;
str1="</channel>";
z=str;
p=str.indexOf(str1);
if(p>-1)y=str.split(str1);
if(p>-1)z=y[1];
return z;
}
String makedes(String str){
String str1,str2;
str1="</description>";
String[] x= str.split(str1);
str2="<description>";
String[] y= x[0].split(str2);
return y[1];
}


String maketitle(String str){
String str1,str2;
str1="</title>";
String[] x= str.split(str1);
str2="<title>";
String[] y= x[0].split(str2);
return y[1];
}

void makearticle(String str){

String str1,str2;
int p,sx;
str1="</item>";
str2="<title>";

String[] x=str.split(str1);
sx=0;
for (s=0;s<x.length;s++){
p=x[s].indexOf(str2);
if(p>-1)sx=sx+1;
if(p>-1)article[sx]=x[s];
}
articlenumber=sx;
}

void getdata(String name){
int num;
int n;
String data[]=new String[1000];

num=0;

try{
        URL url = new URL(name);

        HttpURLConnection con = (HttpURLConnection)url.openConnection();
        con.setRequestMethod("GET");
        con.connect();

        BufferedReader reader =
            new BufferedReader(new InputStreamReader(con.getInputStream(),"UTF-8"));
n=0;
        while (true){
            String line = reader.readLine();
            if ( line == null ){
                break;
            }
data[n]=line;
n=n+1;
num=n;
        }
        reader.close();
        con.disconnect();
}
catch(Exception e) { System.err.println(e); }  
bun="";
for (n=0;n<num;n++){
bun=bun+data[n];
}

}

}
最終更新:2011年03月31日 14:22