您的位置:首页 > 编程语言 > Java开发

帮美女老婆收集基金行情 Java程序

2007-07-28 14:14 295 查看
最近,加息减税后,基金股票行情火爆,美女老婆趋之若渴,每天必上“天天基金网”翻查。她抱怨行数太多了,字体又小。作为心疼本本的我,最怕这些女人乱点广告让机器中“熊猫烧香”之类网页毒。于是我灵机一动,从网页搜查出关键字,然后过滤重新拼成固定的html,再到桌面做快捷方式,每天开机自动运行。哈哈,果然博得美人瓜瓜直叫“你太有才啦!”

与大家分享一下代码:


import java.net.URL;


import java.net.URLConnection;


import java.io.BufferedReader;


import java.io.InputStreamReader;


import java.io.File;


import java.io.FileWriter;


import java.io.PrintWriter;






public class URLReader ...{






public static void main(String[] args) throws Exception ...{


String _findstr1 = "广发聚丰基金";


String _findstr2 = "广发小盘基金";


String _findstr3 = "中小板基金";


String _findstr4 = "易基价值精选基金";




URLConnection yc = (new URL("http://funds.eastmoney.com/"))


.openConnection();


BufferedReader in = new BufferedReader(new InputStreamReader(yc


.getInputStream()));


String inputLine;


File out = new File("aaa.html");


FileWriter fw = new FileWriter(out);


PrintWriter pw = new PrintWriter(fw);


String str = "爱丹丹版1.0<br><table align="center" width="914" border="1" cellspacing="0" cellpadding="2" bordercolorlight="#cccccc" bordercolordark="#FFFFFF">";


pw.print(str);




while ((inputLine = in.readLine()) != null) ...{


if (((inputLine.indexOf(_findstr1)) > 0)


|| ((inputLine.indexOf(_findstr2)) > 0)


|| ((inputLine.indexOf(_findstr3)) > 0)




|| ((inputLine.indexOf(_findstr4)) > 0)) ...{


inputLine = inputLine.substring(inputLine


.indexOf("<tr height=20>"));


pw.print(inputLine);


inputLine = in.readLine();


inputLine = inputLine.substring(0, inputLine


.indexOf("<tr height=20>"));


pw.print(inputLine);


}


}




in.close();


fw.close();


}


}

这个代码的优点就是短小精巧.(哈哈,王婆卖瓜), 缺点就是赋值都是固定的,成了私家专用程序了,想盗版都难啊! 希望朋友你也能用这个逗逗你的心上人吧 :)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: