0

I am trying to access the Yahoo site by getting Stock quotes:

http://de.finance.yahoo.com/d/quotes.csv?s=^DJI&f=nsl1op&e=.csv

and it doesn't seem to be downloading any data. I get "Missing Symbols Listed.". Weird b/c this used to work!

<?php

function market_value($s) {

    $records= fopen ("http://quote.yahoo.com/d/quotes.csv?s=$s&f=nsl1&e=.csv");
    $contents = fread ($records);
    fclose ($records);

    $data = str_replace ("\"", "", $data);
    $data = explode (",", $data);

    $trade= $data[2];

    return (".$trade.")";
}
user118190
  • 2,139
  • 7
  • 29
  • 45
  • You should show us your code *(a short portion of code, that reproduces the problem)*, so we can help you better :-) – Pascal MARTIN Mar 02 '11 at 18:43
  • Removing the `^` brought back a quote, but with `0` for the value. Progress... – Marc B Mar 02 '11 at 19:05
  • possible duplicate of [Yahoo! Finance CSV file will not return Dow Jones (^DJI)](http://stackoverflow.com/questions/3679870/yahoo-finance-csv-file-will-not-return-dow-jones-dji) – phihag Mar 02 '11 at 20:58

2 Answers2

1

^DJI can not be queried from yahoo, as it seems. You should use INDU. Try downloading

http://finance.yahoo.com/d/quotes.csv?s=INDU,GOOG,MSFT&f=nsl1op&e=.csv

This should return something like

"Dow Jones Industr","^DJI",12069.94,12057.34,12058.02
"Google Inc.","GOOG",601.74,600.06,600.76
"Microsoft Corpora","MSFT",26.13,26.10,26.16
Community
  • 1
  • 1
phihag
  • 278,196
  • 72
  • 453
  • 469
  • Thanks for your reply, but the quote I'm looking for is "^DJI". The Down Jones Industrial. – user118190 Mar 02 '11 at 20:48
  • @user118190 Just request INDU then. Updated. – phihag Mar 02 '11 at 20:58
  • Great! What a find! I have been looking for this but couldn't find any references. I read that post, but couldn't find why INDU works and ^DJI does not. Any thoughts? – user118190 Mar 02 '11 at 21:12
  • @user118190 As far as I understand, it's for legal reasons - Dow Jones didn't want everybody to be able to retrieve the current index without using their systems, I guess. Yahoo promptly deleted ^DJI, but left INDU by oversight or because they weren't legally bound to remove that alias. Also, if this answer solves your question, consider accepting it ;) – phihag Mar 02 '11 at 21:21
0

Try getting the DJI quote from Googles HTML

This is an inefficient example in .NET C# (dont know php):

    public async Task<string> MakeGoogleDJIWebRequest()
    {
        string response = await _httpClient.GetStringAsync("http://www.google.com/finance?q=DJI");
        string [] myString = Regex.Split(response, "<span id=\"ref_983582_l\">");
        string [] myString2 = Regex.Split(myString[1], "</span>");
        string [] myString3 = Regex.Split(response, "ref_983582_c\">");
        string [] plusOrMinus = Regex.Split(myString3[1], "</span>");
        string DJI = myString2[0]+ " " + plusOrMinus[0];
        return DJI;
    }

If you just want the value of the DJI and not the +./- just dont add the plusOrMinus[0] above to the return string.

Bizzle
  • 24
  • 2