import java.net.*;
import java.io.*;
class access{
int makeyear,makeday;
String makemonth;
String date[]=new String[100];
int getnumber;
String[] data=new String[1000];
int articlenumber;
String urlx;
double oprice[]=new double[100];
double hprice[]=new double[100];
double lprice[]=new double[100];
double cprice[]=new double[100];
double volume[]=new double[100];
int year[]=new int[100];
String month[]=new String[100];
int day[]=new int[100];
void makedata(String urlx){
int s;
getdata(urlx);
makeitem(getnumber);
for(s=0;s<articlenumber;s++){
makedate(date[s]);
year[s]=makeyear;
month[s]=makemonth;
day[s]=makeday;
}
}
void makedate(String str){
String v0,v1,v2,v3;
String[] v=str.split(",");
v0=v[0];
v1=v[1];
v2=v0.substring(0,3);
String[] vv=v0.split(v2);
v3=vv[1];
v1=v1.trim();
makeyear=Integer.parseInt(v1);
v2=v2.trim();
makemonth=v2;
v3=v3.trim();
makeday=Integer.parseInt(v3);
}
double makeprice(String str){
int n;
double mkp;
String mx;
String[] z=str.split(",");
mx=z[0];
for (n=1;n<z.length;n++){
mx=mx+z[n];
}
mkp=Double.parseDouble(mx);
return mkp;
}
void makeitem(int getnumber){
String data1[]=new String[1000];
int point[]=new int[1000];
String str1;
str1="<td class=";
int n,m,num;
m=0;
for(n=0;n<getnumber;n++){
if(data[n].indexOf(str1)>-1)data1[m]=data[n];
if(data[n].indexOf(str1)>-1)m=m+1;
}
num=m;
m=0;
for(n=0;n<num;n++){
if(data1[n].indexOf("lm")>-1)point[m]=n;
if(data1[n].indexOf("lm")>-1)m=m+1;
}
articlenumber=m;
for (n=0;n<articlenumber;n++){
m=point[n];
String[] x1=data1[m].split(">");
date[n]=x1[1];
String[] x2=data1[m+1].split(">");
oprice[n]=makeprice(x2[1]);
String[] x3=data1[m+2].split(">");
hprice[n]=makeprice(x3[1]);
String[] x4=data1[m+3].split(">");
lprice[n]=makeprice(x4[1]);
String[] x5=data1[m+4].split(">");
cprice[n]=makeprice(x5[1]);
String[] x6=data1[m+5].split(">");
volume[n]=makeprice(x6[1]);
}
}
void getdata(String urlx){
int n;
getnumber=0;
try{
URL url = new URL(urlx);
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;
getnumber=n;
}
reader.close();
con.disconnect();
}
catch(Exception e) { System.err.println(e); }
}
}
最終更新:2011年03月30日 09:40