アットウィキロゴ

がめ0127xx

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

public class game0125{

String data[]=new String[10000];
int m,mx,n,num;
int n1,n2;
int plan[]=new int[100];
String article[]=new String[100];
String output;
String description[]=new String[100];
String name;

public static void main(String[] args){
        
new game0125();
}

game0125(){

name="http://saayaworld.blog70.fc2.com/?xml";

getdata(name);

m=0;
for(n=0;n<num;n++){
if(data[n].indexOf("item")>-1)m=m+1;
if(data[n].indexOf("item")>-1)plan[m]=n;  
}
mx=m/2;
System.out.println(mx);

for(m=1;m<mx;m++){
n1=plan[2*m-1];
n2=plan[2*m]+1;
article[m]="";
for(n=n1;n<n2;n++){
article[m]=article[m]+data[n];
}
}


for (m=3;m<mx;m++){
makedata(article[m],"title");
System.out.println(output);
}




}

void getdata(String name){
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); }
}

void makedata(String str,String keyword){
int n1,n2;
String s1,s2;
s1="<" + keyword + ">";
s2="</" + keyword + ">";
n1=str.indexOf(s1);
n2=str.indexOf(s2);
output=str.substring(n1+7,n2);
}


}
最終更新:2011年03月25日 18:51