Topic: 怎样编写实时获取其它网页内容的WEB PAGE?

  Print this page

1.怎样编写实时获取其它网页内容的WEB PAGE? Copy to clipboard
Posted by: gus
Posted on: 2003-06-16 04:06

请问,怎样编写实时获取其它网页内容的WEB PAGE?例如,我要取得YAHOO的股票价格。有没有个例子看一看?

2.Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re: gus] Copy to clipboard
Posted by: jameszhang
Posted on: 2003-06-16 10:52

写服务程序,用SOCKET读YAHOO的服务器,解析返回信息,应该可以

3.Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re: gus] Copy to clipboard
Posted by: floater
Posted on: 2003-06-16 22:44

check URL class.

4.Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re: gus] Copy to clipboard
Posted by: wduanyang
Posted on: 2003-06-17 09:50

我也正想了解这方面的东西,不知能不能实现?

5.Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re: gus] Copy to clipboard
Posted by: caominfeng
Posted on: 2003-06-17 13:45

YAHOO提供了这个接口了吗?

6.Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re: gus] Copy to clipboard
Posted by: floater
Posted on: 2003-06-18 01:29

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;
}
}

7.Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re: gus] Copy to clipboard
Posted by: 1255
Posted on: 2003-06-18 08:03

QuoteServer is in what package?
How to get it?

8.Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re: floater] Copy to clipboard
Posted by: jameszhang
Posted on: 2003-06-18 11:21

floater wrote:
check URL class.

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

9.Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re: 1255] Copy to clipboard
Posted by: floater
Posted on: 2003-06-18 12:04

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.


   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