アットウィキロゴ

xmlkkjh

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

class game0320{

int s,sx;
int mode;
String urlx;
String bun,chbun;    
int x[]=new int[1000];
int y[]=new int[1000];
int entry1[]=new int[100];
int entry2[]=new int[100];
int source1[]=new int[100];
int source2[]=new int[100];
String[] title=new String[100];
String[] name=new String[100];
String[] published=new String[100];
String[] content=new String[100];
int title1[]=new int[100];
int title2[]=new int[100];
int published1[]=new int[100];
int published2[]=new int[100];
int content1[]=new int[100];
int content2[]=new int[100];
int name1[]=new int[100];
int name2[]=new int[100];
String xml[]=new String[1000];
int z;
int number;
int p1,p2,x1,x2;
int articlenumber;
String cc;


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

game0320(){

urlx="http://www.google.com/alerts/feeds/01098385978506698295/16131640761661536264";

getdata(urlx);

s=1;
mode=0;
z=bun.indexOf("<");
x[1]=z;
while(mode<50){
z=bun.indexOf("<",z+1);
if(z>-1)s=s+1;
if(z>-1)x[s]=z;
if(z<0)mode=100;
}


s=1;
mode=0;
z=bun.indexOf(">");
y[1]=z;
while(mode<50){
z=bun.indexOf(">",z+1);
if(z>-1)s=s+1;
if(z>-1)y[s]=z;
if(z<0)mode=100;
}

number=s;

for(s=1;s<number+1;s++){
p1=x[s];
p2=y[s];
xml[s]=bun.substring(p1+1,p2);
}

sx=0;
for (s=1;s<number+1;s++){
p1=xml[s].indexOf("entry");
p2=xml[s].indexOf("/entry");
if(p2>-1)p1=-999;
if(p1>-1)sx=sx+1;
if(p1>-1)entry1[sx]=s;
if(p2>-1)entry2[sx]=s;
}

articlenumber=sx;

for (s=1;s<articlenumber+1;s++){
p1=entry1[s];
p2=entry2[s];
for(sx=p1;sx<p2;sx++){
x1=xml[sx].indexOf("source");
x2=xml[sx].indexOf("/source");
if(x2>-1)x1=-999;
if(x1>-1)source1[s]=sx;
if(x2>-1)source2[s]=sx;
}
}


for (s=1;s<articlenumber+1;s++){
p1=entry1[s];
p2=source1[s];
for(sx=p1;sx<p2;sx++){
x1=xml[sx].indexOf("title");
x2=xml[sx].indexOf("/title");
if(x2>-1)x1=-999;
if(x1>-1)title1[s]=sx;
if(x2>-1)title2[s]=sx;
}
}

for (s=1;s<articlenumber+1;s++){
p1=entry1[s];
p2=entry2[s];
for(sx=p1;sx<p2;sx++){
x1=xml[sx].indexOf("published");
x2=xml[sx].indexOf("/published");
if(x2>-1)x1=-999;
if(x1>-1)published1[s]=sx;
if(x2>-1)published2[s]=sx;
}
}

for (s=1;s<articlenumber+1;s++){
p1=entry1[s];
p2=entry2[s];
for(sx=p1;sx<p2;sx++){
x1=xml[sx].indexOf("content");
x2=xml[sx].indexOf("/content");
if(x2>-1)x1=-999;
if(x1>-1)content1[s]=sx;
if(x2>-1)content2[s]=sx;
}
}


for (s=1;s<articlenumber+1;s++){
p1=entry1[s];
p2=entry2[s];
for(sx=p1;sx<p2;sx++){
x1=xml[sx].indexOf("name");
x2=xml[sx].indexOf("/name");
if(x2>-1)x1=-999;
if(x1>-1)name1[s]=sx;
if(x2>-1)name2[s]=sx;
}
}


for(s=1;s<articlenumber+1;s++){
p1=y[title1[s]];
p2=x[title2[s]];
title[s]=bun.substring(p1+1,p2);
}

for(s=1;s<articlenumber+1;s++){
p1=y[content1[s]];
p2=x[content2[s]];
content[s]=bun.substring(p1+1,p2);
}

for(s=1;s<articlenumber+1;s++){
p1=y[published1[s]];
p2=x[published2[s]];
published[s]=bun.substring(p1+1,p2);
}

for(s=1;s<articlenumber+1;s++){
p1=y[name1[s]];
p2=x[name2[s]];
name[s]=bun.substring(p1+1,p2);
}

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







}

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

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日 21:58