Downloading LIVE yahoo quotes into an html page

G

gojakie

Dear friends,

I would like to have a html page which updates/auto-refreshes realtime
quotes of stock exchanges in India which is Nifty NSE. I have seen few
programs in Excel VBA, .net and other languages which serves the
purpose. I would like to know if this can be done in javascript. i
would like to have a table consisting of 7 rows and 10 columns (row
one for heading) Once the quotes are updated, I would like to sort it
using few javascripts like tablesorter.js that I have seen. Can
somebody help me with this?

I want to add the following scrips in the html page in column 2 of the
table.

^NSEI.NS UNITECH.NS, SUZLON.NS, RPL.NS RNRL.NS HINDALDO.NS and there
might be few more that I may want to add in the future.

---------------------------------

I would like to share an Excel VBA module that I saw in trajerji.com.
This example will show exactly what kind of output I am looking for.
Following is the code. It takes the name of the company, the symbol,
the current share value, date, time, change %, open, high, low and
volume. It takes if from the url
http://in.finance.yahoo.com/d/quotes.csv?s=UNITECH.NS,SUZLON.NS,&f=nsl1d1t1c1ohgv&e=.csv

Open Excel, press ALT+F11, click on Insert->Module and paste the code.
Go back to excel and press ALT+F8 and run the code to see the result.

Sub getDataFromYahooCSV()

strURL = "http://in.finance.yahoo.com/d/quotes.csv?
s=UNITECH.NS,SUZLON.NS,&f=nsl1d1t1c1ohgv&e=.csv"
With ActiveWorkbook.ActiveSheet.QueryTables.Add(Connection:="URL;"
& strURL, Destination:=ActiveSheet.Cells(3, 255))
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
End With
'replace the ""
Range("IV1").Select
ActiveCell.FormulaR1C1 = "=SUBSTITUTE(RC[-1],"""""""","""")"

Selection.AutoFill Destination:=Range("IV1:IV10")
'break it to different column
csv 3
'auto fit them
Columns("A:K").Select
Columns("A:K").EntireColumn.AutoFit
Range("A1").Select
End Sub
Sub csv(j As Integer)
k = 3
row_no = j
While Len(Trim(Cells(k, 256).Value)) > 0

TempString = Trim(Cells(k, 256).Value) & ","
col_no = 1
While (InStr(1, TempString, ","))
Cells(row_no, col_no).Value = Mid(TempString, 1, InStr(1,
TempString, ",") - 1)
TempString = Mid(TempString, InStr(1, TempString, ",") + 1, Len
(TempString) - InStr(1, TempString, ","))
col_no = col_no + 1
Wend
k = k + 1
row_no = row_no + 1
Wend
'this will be deleting the data got once it serves its purpose
Columns("IU:IV").Select
Selection.QueryTable.Delete
Columns("IU:IV").Delete Shift:=xlToLeft
End Sub

-------------

Another one I saw which I believe is made in .Net
http://www.codeproject.com/KB/gadgets/StockBag.aspx?display=PrintAll

The significant difference in this one is that besides the things
which excel vba downloads, it also downloads some more information
like market capital, previous close, earnings, PE ratio etc.

-------------
 
G

gojakie

I have googled for special tags which can be extracted. I will be very
glad if someone can help me get these into html page for the scrips
that I have listed. I would like to change my html table grid to 7
rows and 11 columns

s Symbol
l1 CMP
c1 Change
p2 % Change
o Open
h High
g Low
p Prev Close
v Volume
j 52W Low
k 52W High

Here is the updated url:
http://in.finance.yahoo.com/d/quote...,RNRL.NS,HINDALcO.NS,&f=sl1c1p2ohgpvjk&e=.csv

Here is the output of the url:
Symbol CMP Change Change% Open High Low PrevClose Volume 52WLow
52WHigh
UNITECH.NS 38.4 0.5 1.32% 38 39.6 37 37.9 47429680 21.65 337.8
VIDEOIND.NS 125 20.85 20.02% 104 125 104 104.15 662947 87 871.2
SUZLON.NS 58 3.55 6.52% 53.8 59.1 53.8 54.45 42000652 36.2 1994.6
RPL.NS 90.45 0.35 0.39% 90.1 91.8 88.35 90.1 17131396 68.35 259.8
HDFC.NS 1546.2 -66.55 -4.13% 1602.2 1608 1528 1612.75 3668513 1200
3262
RNRL.NS 57.45 -1.35 -2.30% 57.9 59.4 56.3 58.8 41732544 47.8 248.25
HINDALCO.NS 56.05 0.2 0.36% 56 58 54.8 55.85 4783085 51.1 221.45
 
G

GoJakie

I am going for a php solution. The following code worked. I googled it
for a while and got this code from somewhere on the Internet. This
code is for those who are struggling like me. All the best
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top