获取谷歌财务数据

发布于 2024-09-03 14:53:37 字数 30 浏览 8 评论 0原文

谁能给我一个关于如何获取谷歌财经实时股票的例子

can anyone provide me an example on how I can fetch the real-time stocks of google finance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

怕倦 2024-09-10 14:53:37

遇到这个(和你的帖子)试图自己解决这个问题......

这个目前检索一些 XML:

http://www.google.com/ig/api?stock=F

当然他们也可能很快关闭它...

我认为 'last data=' 将给出当前引用

编辑:

API 现在是 完全关闭并且不再起作用。 “实时”报价的“api”的替代方案是:

http://finance.google.com/finance/info?client=ig&q=NYSE:F

Came across this (and your post) trying to figure this out myself...

This currently retrieves some XML:

http://www.google.com/ig/api?stock=F

Of course they may close this down as well soon...

I think 'last data=' will give current quote

EDIT:

The api is now completely shutdown and no longer works. An alternative to 'api' for a 'realtime' quote would be:

http://finance.google.com/finance/info?client=ig&q=NYSE:F
尸血腥色 2024-09-10 14:53:37

截至目前(2015 年),Google 财经 API 已被弃用。如果您熟悉 Python,则可以使用 pypi 模块 googlefinance

安装googlefinance

$pip install googlefinance

获取当前股票价格很容易:

>>> from googlefinance import getQuotes
>>> import json
>>> print json.dumps(getQuotes('AAPL'), indent=2)
[
  {
    "Index": "NASDAQ", 
    "LastTradeWithCurrency": "129.09", 
    "LastTradeDateTime": "2015-03-02T16:04:29Z", 
    "LastTradePrice": "129.09", 
    "Yield": "1.46", 
    "LastTradeTime": "4:04PM EST", 
    "LastTradeDateTimeLong": "Mar 2, 4:04PM EST", 
    "Dividend": "0.47", 
    "StockSymbol": "AAPL", 
    "ID": "22144"
  }
]

Google Finance是提供实时股票数据的来源。还有其他来自yahoo的API,例如yahoo-finance,但延迟15分钟纽约证券交易所和纳斯达克股票。

As for now (2015), the google finance api is deprecated. If you are comfortable with python, you may use the pypi module googlefinance.

Install googlefinance

$pip install googlefinance

It is easy to get current stock price:

>>> from googlefinance import getQuotes
>>> import json
>>> print json.dumps(getQuotes('AAPL'), indent=2)
[
  {
    "Index": "NASDAQ", 
    "LastTradeWithCurrency": "129.09", 
    "LastTradeDateTime": "2015-03-02T16:04:29Z", 
    "LastTradePrice": "129.09", 
    "Yield": "1.46", 
    "LastTradeTime": "4:04PM EST", 
    "LastTradeDateTimeLong": "Mar 2, 4:04PM EST", 
    "Dividend": "0.47", 
    "StockSymbol": "AAPL", 
    "ID": "22144"
  }
]

Google finance is a source that provides real-time stock data. There are also other APIs from yahoo, such as yahoo-finance, but they are delayed by 15min for NYSE and NASDAQ stocks.

〃温暖了心ぐ 2024-09-10 14:53:37

一段时间以来,我一直在努力寻找这些数据的终身免费访问权限,但今天我遇到了 Alpha Vantage (https://www.alphavantage.co)并使用他们的数据从 Google 图表构建带注释的时间轴。
您所需要的只是请求一个 API 密钥(您在填写表格时获得)并遵循他们的文档。

在 PHP 中获取 JSON 输出的示例:

$url = file_get_contents('https: //www.alphavantage.co/query?function=TIME_SERIES_DAILY&outputsize=full&symbol=AAPL&apikey='.$apiKey);
$decoded = json_decode($url, true);

I've been struggling with trying to find a lifetime free access for this data for some time as well, but today I came across Alpha Vantage (https://www.alphavantage.co) and used their data to build an Annotated Timeline from Google Charts.
All you need is to request an API Key (which you get at the moment you fill in their form) and follow their Documentation.

An example of getting a JSON output in PHP:

$url = file_get_contents('https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&outputsize=full&symbol=AAPL&apikey='.$apiKey);
$decoded = json_decode($url, true);

荆棘i 2024-09-10 14:53:37

当我尝试时,先前答案中的链接已损坏,因此这里是另一个示例。你必须做一些处理,但除此之外它很容易。
http://www.google.com/finance/info?client =ig&q=goog,微软

The link in the earlier answer was broken when I tried it, so here is another example. You have to do a bit of processing but otherwise it's pretty easy.
http://www.google.com/finance/info?client=ig&q=goog,msft

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文