Has Yahoo suddenly today terminated its finance do

2019-01-02 23:41发布

For months I've been using a url like this, from perl:

http://finance.yahoo.com/d/quotes.csv?s=$s&f=ynl1 #returns yield, name, price;

Today, 11/1/17, it suddenly returns a 999 error.

Is this a glitch, or has Yahoo terminated the service?

I get the error even if I enter the URL directly into a browser as, eg:

http://finance.yahoo.com/d/quotes.csv?s=INTC&f=ynl1

so it doesn't seem to be a 'crumb' problem.

Note: This is NOT a question which has been answered in the past! It was working yesterday.That it happened on the first of the month is suspicious.

6条回答
Lonely孤独者°
2楼-- · 2019-01-03 00:05

As noted in the other answers and elsewhere (e.g. currency helper of yahoo - Sorry, Unable to process request at this time -- error 999), Yahoo has indeed ceased operation of the Yahoo Finance API. However, as a workaround, you can access a trove of financial information, in JSON format, for a given ticker symbol, by doing a HTTPS GET request to: https://finance.yahoo.com/quote/SYMBOL (e.g. https://finance.yahoo.com/quote/MSFT). If you do a GET request to the above URL, you'll see that the financial data is contained within the response in JSON format. The following python script shows how you can parse individual values that you may be interested in:

import requests
import json

symbol='MSFT'
url='https://finance.yahoo.com/quote/' + symbol
resp = requests.get(url)

#parse the section from the html document containing the raw json data that we need
#you can write jsonstr to a file, then open the file in a web browser to browse the structure of the json data
r=resp.text.encode('utf-8')
i1=0
i1=r.find('root.App.main', i1)
i1=r.find('{', i1)
i2=r.find("\n", i1)
i2=r.rfind(';', i1, i2)
jsonstr=r[i1:i2]      


#load the raw json data into a python data object
data = json.loads(jsonstr)

#pull the values that we are interested in 
name=data['context']['dispatcher']['stores']['QuoteSummaryStore']['price']['shortName']
price=data['context']['dispatcher']['stores']['QuoteSummaryStore']['price']['regularMarketPrice']['raw']
change=data['context']['dispatcher']['stores']['QuoteSummaryStore']['price']['regularMarketChange']['raw']
shares_outstanding=data['context']['dispatcher']['stores']['QuoteSummaryStore']['defaultKeyStatistics']['sharesOutstanding']['raw']
market_cap=data['context']['dispatcher']['stores']['QuoteSummaryStore']['summaryDetail']['marketCap']['raw']
trailing_pe=data['context']['dispatcher']['stores']['QuoteSummaryStore']['summaryDetail']['trailingPE']['raw']
earnings_per_share=data['context']['dispatcher']['stores']['QuoteSummaryStore']['defaultKeyStatistics']['trailingEps']['raw']
forward_annual_dividend_rate=data['context']['dispatcher']['stores']['QuoteSummaryStore']['summaryDetail']['dividendRate']['raw']
forward_annual_dividend_yield=data['context']['dispatcher']['stores']['QuoteSummaryStore']['summaryDetail']['dividendYield']['raw']

#print the values
print 'Symbol:', symbol
print 'Name:', name
print 'Price:', price
print 'Change:', change
print 'Shares Outstanding:', shares_outstanding
print 'Market Cap:', market_cap
print 'Trailing PE:', trailing_pe
print 'Earnings Per Share:', earnings_per_share
print 'Forward Annual Dividend Rate:', forward_annual_dividend_rate
print 'Forward_annual_dividend_yield:', forward_annual_dividend_yield

The output of the script should look something like this:

Symbol: MSFT
Name: Microsoft Corporation
Price: 84.14
Change: 0.08999634
Shares Outstanding: 7714590208
Market Cap: 649105637376
Trailing PE: 31.04797
Earnings Per Share: 2.71
Forward Annual Dividend Rate: 1.68
Forward_annual_dividend_yield: 0.02
查看更多
乱世女痞
3楼-- · 2019-01-03 00:15

What are you complaining about? You can still go to Yahoo and view the quote for any ticker symbol and write it down or type it into a spreadsheet. In fact, you can do this for a whole list of symbols.

What I can no longer do is download today's data for a whole list of symbols in spreadsheet format. At least I did that this morning. Now, suddenly, my computer cannot make a "secure connection" to Yahoo finance.

I am curious what terms of service were violated. Did somebody find a way to use the data profitably? That, of course, would be grossly immoral, unless all profits were donated to a worthy non-racist cause like the government of Zimbabwe or Venezuela.

This is the SECOND TIME that Yahoo has made it difficult to get data. I hereby forecast that in the future your requested data will be formatted as a .PNG file with a crazy font that defies any attempt at OCR.

查看更多
Animai°情兽
4楼-- · 2019-01-03 00:16

var API = "https://query1.finance.yahoo.com/v7/finance/quote?symbols=AAPL"; $.getJSON(API, function (json) {...});call throws this error: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.microplan.at/sar' is therefore not allowed access.

查看更多
走好不送
5楼-- · 2019-01-03 00:17

Yahoo confirmed that they terminated the service:

It has come to our attention that this service is being used in violation of the Yahoo Terms of Service. As such, the service is being discontinued. For all future markets and equities data research, please refer to finance.yahoo.com .

查看更多
淡お忘
6楼-- · 2019-01-03 00:26

There is still a way to get this data by querying some APIs used by the finance.yahoo.com page. Not sure if Yahoo will be supporting it long term as the previous API was (hopefully they will).

I adapted the method used by https://github.com/pstadler/ticker.sh into the following python hack that takes a list of symbols from the command line and outputs some of the variables as a csv:

#!/usr/bin/env python

import sys
import time
import requests

if len(sys.argv) < 2:
    print("missing parameters: <symbol> ...")
    exit()

apiEndpoint = "https://query1.finance.yahoo.com/v7/finance/quote"
fields = [
    'symbol',
    'regularMarketVolume',
    'regularMarketPrice',
    'regularMarketDayHigh',
    'regularMarketDayLow',
    'regularMarketTime',
    'regularMarketChangePercent']
fields = ','.join(fields)
symbols = sys.argv[1:]
symbols = ','.join(symbols)
payload = {
    'lang': 'en-US',
    'region': 'US',
    'corsDomain': 'finance.yahoo.com',
    'fields': fields,
    'symbols': symbols}
r = requests.get(apiEndpoint, params=payload)
for i in r.json()['quoteResponse']['result']:
    if 'regularMarketPrice' in i:
        a = []
        a.append(i['symbol'])
        a.append(i['regularMarketPrice'])
        a.append(time.strftime(
            '%Y-%m-%d %H:%M:%S', time.localtime(i['regularMarketTime'])))
        a.append(i['regularMarketChangePercent'])
        a.append(i['regularMarketVolume'])
        a.append("{0:.2f} - {1:.2f}".format(
            i['regularMarketDayLow'], i['regularMarketDayHigh']))
        print(",".join([str(e) for e in a]))

Sample Run:

$ ./getquotePy.py AAPL GOOGL
AAPL,174.5342,2017-11-07 17:21:28,0.1630961,19905458,173.60 - 173.60
GOOGL,1048.6753,2017-11-07 17:21:22,0.5749836,840447,1043.00 - 1043.00
查看更多
The star\"
7楼-- · 2019-01-03 00:31

My Python program using Yahoo Finance has recently stopped working properly, but it didn't return that error, it just replaced stock prices with 0's. I initially saw this when I debugged and then, when I went to the yahoo finance URLS for those stocks, I confirmed the error. Since the actual data is messed up, I don't think the work-arounds that have been suggested would fix my problems. Is this likely related to yahoo discontinuing their API? I can't understand what could explain this.

Examples:

查看更多
登录 后发表回答