Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 怎样编写实时获取其它网页内容的WEB PAGE?
gus



发贴: 0
积分: 0
于 2003-06-16 04:06 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
请问,怎样编写实时获取其它网页内容的WEB PAGE?例如,我要取得YAHOO的股票价格。有没有个例子看一看?


作者 Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re:gus]
jameszhang



CJSDN高级会员


发贴: 1594
积分: 111
于 2003-06-16 10:52 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
写服务程序,用SOCKET读YAHOO的服务器,解析返回信息,应该可以


"First they ignore u, then they laugh at u, then they fight u, then u will win

Mahatma Gandhi"

作者 Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re:gus]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2003-06-16 22:44 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
check URL class.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re:gus]
wduanyang



发贴: 0
积分: 0
于 2003-06-17 09:50 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我也正想了解这方面的东西,不知能不能实现?


作者 Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re:gus]
caominfeng



发贴: 0
积分: 0
于 2003-06-17 13:45 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
YAHOO提供了这个接口了吗?


作者 Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re:gus]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2003-06-18 01:29 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Yes, it has a link for daily quote. Fetch the info from below


package quote;

import java.util.*;
import utils.*;

public class YahooQuoteServer implements QuoteServer
{
public String getURL(KeyPairs quoteParams)
{
String startDate = quoteParams.getStringValue(START_DATE, "");
String endDate = quoteParams.getStringValue(END_DATE, "");
String stockSymbol = quoteParams.getStringValue(STOCK_SYMBOL, "");
String scale = quoteParams.getStringValue(TIME_INTERVAL, "d"); //default to daily

if (!checkDateFormat(startDate) || !checkDateFormat(endDate))
{
return WRONG_DATE_FORMAT;
}
StringTokenizer ssDate = new StringTokenizer(startDate, "/");
StringTokenizer seDate = new StringTokenizer(endDate, "/");
String sMonth = ssDate.nextToken();
String sDay = ssDate.nextToken();
String sYear = ssDate.nextToken();
String eMonth = seDate.nextToken();
String eDay = seDate.nextToken();
String eYear = seDate.nextToken();

String returnURL = new String("http://chart.yahoo.com/");
returnURL += "table.csv?&s=" + stockSymbol;
returnURL += "&a=" + sMonth + "&b=" + sDay + "&c=" + sYear;
returnURL += "&d=" + eMonth + "&e=" + eDay + "&f=" + eYear;
returnURL += "&g=" + scale + "&q=q&y=0&z=" + stockSymbol + "&x=.csv";

return returnURL;

}

// This will check the string to be in the format of XX/XX/XXXX
// where X is a digit 0-9
public static boolean checkDateFormat(String s)
{
String num = "0123456789";

if (s.length() != 10) return false;
if (num.indexOf(s.charAt(0)) == -1) return false;
if (num.indexOf(s.charAt(1)) == -1) return false;
if (s.charAt(2) != '/') return false;
if (num.indexOf(s.charAt(3)) == -1) return false;
if (num.indexOf(s.charAt(4)) == -1) return false;
if (s.charAt(5) != '/') return false;
if (num.indexOf(s.charAt(6)) == -1) return false;
if (num.indexOf(s.charAt(7)) == -1) return false;
if (num.indexOf(s.charAt(8)) == -1) return false;
if (num.indexOf(s.charAt(9)) == -1) return false;
return true;
}
}



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re:gus]
1255





发贴: 32
积分: 0
于 2003-06-18 08:03 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
QuoteServer is in what package?
How to get it?



作者 Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re:floater]
jameszhang



CJSDN高级会员


发贴: 1594
积分: 111
于 2003-06-18 11:21 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
floater wrote:
check URL class.

还是总斑竹的方法简单,呵呵!
Wink



"First they ignore u, then they laugh at u, then they fight u, then u will win

Mahatma Gandhi"

作者 Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re:1255]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2003-06-18 12:04 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1255 wrote:
QuoteServer is in what package?
How to get it?

Ignore that, just use the code to figure out the url link to the quote.

It's my own package. I used to get daily quote from yahoo.



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923