eric6304 Posted June 28, 2004 Posted June 28, 2004 Hi, I would like to get a real-time quote from the Internet, then display the quote price in a textbox on a VB.Net Windows Form. Here are the basic steps to get the quote manually: 1). Open IE 6.0, type in a URL at address location: http://finance.yahoo.com/q/ecn?s=MSFT 2). It will display a real-time quote for Microsoft, such as Last Trade: 28.22 ====================== 3). If you view the HTML Source page and search for "Last Trade:" string, it will show the following line embedded inside lots of HTML codes. ----------------------------------------------------------- Last Trade:</td><td class="yfnc_tabledata1"><b>28.22</b> ----------------------------------------------------------- My question is how can you make a copy of this Microsoft last trade price (28.22) and display it in a textbox on VB.Net Windows Form? Thanks in advance for your help, Quote
Moderators Robby Posted June 28, 2004 Moderators Posted June 28, 2004 look into using Net.WebClient() Quote Visit...Bassic Software
eric6304 Posted June 29, 2004 Author Posted June 29, 2004 Robby, Thanks for your quick hint. I just looked at WebClient. There are three kinds of method available. 1). The DownloadData method downloads data from a resource and then returns a byte array. 2). The DownloadFile method downloads data from a resource to a local file. 3). The OpenRead method returns the data from the resource as a stream. Which method do you recommand me to use in this case? There will be over thousands of HTML tags and words in a single web page, I just need copying one data (last trade: 28.22) from them. look into using Net.WebClient() Quote
Moderators Robby Posted June 29, 2004 Moderators Posted June 29, 2004 OpenRead will stream the contents of the page to you so you can parse it. DownLoadFile allows you to download files such as images here's a sample.... Dim sr As IO.StreamReader Dim wc As New Net.WebClient() sr = New IO.StreamReader(wc.OpenRead(THE_URL)) sim s as string s = sr.ReadToEnd sr.DiscardBufferedData() sr.Close() wc.Dispose() 's will contain all the html Quote Visit...Bassic Software
eric6304 Posted June 29, 2004 Author Posted June 29, 2004 Robby, Thanks a lot for your time and expert opinion. Eric OpenRead will stream the contents of the page to you so you can parse it. DownLoadFile allows you to download files such as images here's a sample.... Dim sr As IO.StreamReader Dim wc As New Net.WebClient() sr = New IO.StreamReader(wc.OpenRead(THE_URL)) sim s as string s = sr.ReadToEnd sr.DiscardBufferedData() sr.Close() wc.Dispose() 's will contain all the html Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.