467,119 Members | 1,171 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,119 developers. It's quick & easy.

How to login yahoo finance

I need how to log in Yahoo finance through VB.NET code to fetch the real time stock market data here I am posting some code through which I am download data from yahoo but this is not real time data only I will get real time data after log in to yahoo finance
Expand|Select|Wrap|Line Numbers
  1. Imports System
  2. Imports System.IO
  3. Imports System.Net
  4. Imports System.Text
  5.  
  6. Public Class Form1
  7.  
  8.  
  9.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  10.  
  11.         Dim symbol As [String] = txtQuotes.Text
  12.  
  13.         Dim request As HttpWebRequest
  14.         Dim response As HttpWebResponse = Nothing
  15.         Dim reader As StreamReader
  16.  
  17.         Try
  18.  
  19.             ''request = WebRequest.Create("http://finance.yahoo.com/d/quotes.csv?s=Reliance.ns&f=sl1d1t1c1ohgv&e=.csv")
  20.  
  21.             'request = WebRequest.Create("http://quote.yahoo.com/d/quotes.csv?s=Reliance.ns&f=sl1d1t1c1ohgv&e=.csv")
  22.  
  23.             request = WebRequest.Create("http://finance.yahoo.com/d/quotes.csv?s=" & symbol & "&f=sl1d1t1c1ohgv&e=.csv")
  24.             request.Method = "POST"
  25.             ' Get response 
  26.             request.ContentType = "text/xml"
  27.             ''request.Headers.Add("SOAPAction", "http://finance.yahoo.com/d/quotes.csv?s=Reliance.ns&f=sl1d1t1c1ohgv&e=.csv")
  28.  
  29.             request.Headers.Add("SOAPAction", "http://finance.yahoo.com/d/quotes.csv?s=" & symbol & "&f=sl1d1t1c1ohgv&e=.csv")
  30.  
  31.             'request.Headers.Add("SOAPAction", "http://quote.yahoo.com/d/quotes.csv?s=Reliance.ns&f=sl1d1t1c1ohgv&e=.csv")
  32.             response = DirectCast(request.GetResponse(), HttpWebResponse)
  33.  
  34.             reader = New StreamReader(response.GetResponseStream())
  35.             txtOutput1.Text = (reader.ReadToEnd())
  36.  
  37.         Finally
  38.             If Not response Is Nothing Then response.Close()
  39.         End Try
  40.     End Sub
  41.  
  42.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  43.         Dim s As String() = txtOutput1.Text.Split(",")
  44.         Dim word As String
  45.         'Dim dv As DataGridViewRow
  46.         Dim dgvRow As New DataGridViewRow
  47.         For Each word In s
  48.  
  49.             Dim dgvCell As DataGridViewCell
  50.  
  51.             dgvCell = New DataGridViewTextBoxCell()
  52.             dgvCell.Value = word
  53.  
  54.             dgvRow.Cells.Add(dgvCell)
  55.             'dg1.Columns.Add("Column Name", "Column Heading")
  56.  
  57.  
  58.         Next
  59.         dg1.Rows.Add(dgvRow)
  60.  
  61.     End Sub
  62. End Class
Aug 6 '11 #1
  • viewed: 2649
Share:
1 Reply
Paul Johnson
Does your code actually log you into Yahoo for the real time data? As it stands, you're just reading (as you say), the static data - however, you're not actually doing anything with it.

Button1 does the connection and outputs the stream, Button3 looks to add data to a grid, but there is no connection between them.

I don't know if yahoo connects in the same way as gmail, but this may help (sorry, it's in C#, but easily ported over)

http://www.all-the-johnsons.co.uk/csharp/email.html

PFJ
Aug 8 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by bryce21 | last post: by
6 posts views Thread by f | last post: by
13 posts views Thread by dan roberts | last post: by
4 posts views Thread by joe_public34 | last post: by
1 post views Thread by Andrew | last post: by
2 posts views Thread by James | last post: by
reply views Thread by =?Utf-8?B?Unlhbg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.