In order to receive the data back and parse it for whatever you can do
something like this:

URL u = new URL("www.yahoo.com/whatever"); // URL to post data to

    URLConnection uc = u.openConnection();
    uc.setUseCaches(false);
    uc.setDoOutput(true); // Lets you write to the connection
    Writer out = new BufferedWriter(new
OutputStreamWriter(uc.getOutputStream(), "ISO-8859-1"));

    out.write(parameter values); // Whatever values that your site is
expecting
    out.flush();
    out.close();

    InputStreamReader r = new InputStreamReader(uc.getInputStream());

        Then you can just keep doing r.read until the entire page is read or you
have found what you want.

        You may want to take a look at using threads to automate your lookups since
they are better suited for this sort of thing I believe.

        ~Matt Penner

 -----Original Message-----
From:   A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]  On Behalf Of Kronos
B
Sent:   Wednesday, November 29, 2000 10:14 PM
To:     [EMAIL PROTECTED]
Subject:        Question: servlet to extract HTML from a webpage

Hi,
This question might be really basic, but I just 2 weeks old as a servlet
developer.

I have written a servlet which serves as a stock quote wrapper, ie, if you
type a stock ticker, say MSFT in the box provided, the servlet sends the
request to yahoo-finance, and gets the results. This servlet is doing
nothing terrific...the same thing can be done by going to Yahoo-finance
directly!

However, I want this servlet to go to that yahoo-finance page, extract
that specific stock quote, compare it with a threshold value, and generate
an alert if the stock has fallen below the threshold.

So I need to know two things: How to extract HTML from the Yahoo-finance
page using a servlet?<Then I will parse it to get the stock quote>

#2 How do I make this servlet repeat the stuff every 1 minute(say) to
constantly keep monitoring the stock? <will a 'C' style loop, like
while(1) do?>

I *really* appreciate your help in this regard!

Thanks in advance!

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to