谷歌金融json股票报价停止工作 [英] google finance json stock quote stopped working

查看:100
本文介绍了谷歌金融json股票报价停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我一直使用此URL从Google财经获取股票报价,并使用PHP解析json数据:

So far I was using this URL to get stock quotes from google finance, and parsing the json data using PHP:

http://finance.google.com/finance/info?client=ig&q=nse:infy,nasdaq:aapl

今天它停止工作了 但是,我仍然可以访问此地址:

Today it stopped working However, I can still access this one:

http://finance.google.com/finance/?client=ig&q=nse:infy

问题在于,这只返回单只股票的报价,而不是像以前那样返回多只股票的报价...

The problem is that this one is only returning quotes for a single stock, and not multiple ones like previous one used to do...

任何人都知道如何使用此URL获得多只股票的股票报价吗? 当我这样尝试时:

Anyone knows how to get stock quotes for multiple stocks using this URL? When I tried like this:

http://finance.google.com/finance/?client=ig&q=nse:infy,nse:ashokley

它仍然返回一些json,表明两只股票都处于活跃状态.但这不包括引号等... 任何帮助,我们将不胜感激.

it still returns some json stating that both stocks are active. But it won't include quotes etc... Any help is greatly appreciated.

或者,如果无法从此处获取该信息,请指向其他可以获取类似股票的OHLCV数据的地方.

Or if its not possible to get it from here, please point me to another place where I can get OHLCV data for similar stocks.

于2018年8月4日更新 Google实时盘中补余广告也已停止工作.下面的URL将重定向到该符号的google搜索页面.

Updating on 04 Aug, 2018 Google realtime intraday backfill has also stopped working. The below URL will redirect to google search page for the symbol.

https://finance.google.com/finance/getprices?p=1d&f=d,o,h,l,c,v&q=NIFTY&x=NSE&i=60

推荐答案

正如Peter Said所说,Google Finance API将于2012年10月关闭.Google在不支持或监视服务器的情况下使服务器无法运行.当发现重大错误或安全漏洞时,它们将关闭服务器,如Jeff Nelson

As Peter Said, Google Finance API was to shut down on October 2012. Google left the servers functioning without supporting or monitoring them. They will turn off the servers when a major bug or security hole is discovered as mentioned by Jeff Nelson here.

您可以使用Yahoo finance来获取多个股票代码的价格,如下所示:

You can use Yahoo finance to get the prices for multiple stock symbols as follow :http://finance.yahoo.com/d/quotes.csv?s=AAPL+GOOG+MSFT&f=snbaopl1

Google股票代码: https://finance.google.com/finance?q=NASDAQ:AAPL& ; output = json

Google Ticker: https://finance.google.com/finance?q=NASDAQ:AAPL&output=json

或者您可以使用 Google实时日内回填数据.

这是有关上述google API的概述,因为它是一个棘手的难题. 我将使用您在评论中编写的网址: https://www.google.com/finance/getprices?q=.NSEI&x=NSE&i=600&p=1d&f=d,o,h,l,c,v

This is an overview about the above google api since it is a litile tricky. I will use the url you wrote in the comment: https://www.google.com/finance/getprices?q=.NSEI&x=NSE&i=600&p=1d&f=d,o,h,l,c,v

这里的参数i(interval)= 600秒= 10分钟.

Here the parameter i(interval) = 600 seconds = 10 minutes.

第一列(日期)有一个棘手的位,带有完整和部分的时间戳.(请检查图像中的注释)

One tricky bit with the first column(date) has the full and partial timestamp.(Please check the notes in image )

第一行的时间戳=1504669800.图像数据集中的第二行的间隔为1.您可以将该数字乘以间隔大小(在本示例中为600 s),然后将其添加到最后一个Unix中时间戳记.这样就为您提供了当前行的日期. (因此,第二排比第一排晚10分钟.很简单.)

The first row has timestamp = 1504669800. The second row in the data set in image has an interval of 1. You can multiply this number by our interval size (600 s, in this example) and add it to the last Unix Timestamp. That gives you the date for the current row. (So our second row is 10 minutes after the first row. Easy.)

1504669800 + (1 * 600) = 1504670400 -> timestamp for second row
1504670400 + (2 * 600) = 1504671600 -> timestamp for Third row ... and so on.

最后一行(底部)具有最高日期和最新刻度.

The last row (in the bottom) has the highest date and the latest tick.

很容易以任何编程语言(例如php示例)将Unix时间戳转换为格式化日期:

It is easy to convert the unix time stamp to formatted date in any programming language, php example:

<?php
$timestamp=1504669800;
echo gmdate("Y-m-d\TH:i:s\Z", $timestamp);
?>

此处的在线转换器

希望获得帮助.

这篇关于谷歌金融json股票报价停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆