Php 有哪些选项可以从不再存在的ASP网站获取股票数据?
我使用codeigniter作为一个框架编写了这段PHP代码,它所做的一切都是从Google股票中获取最新信息:Php 有哪些选项可以从不再存在的ASP网站获取股票数据?,php,asp.net,codeigniter,Php,Asp.net,Codeigniter,我使用codeigniter作为一个框架编写了这段PHP代码,它所做的一切都是从Google股票中获取最新信息: { section name="company" loop=$stock} <hr noshade size="1" width="100%"> <table width="100%" border="0"> <tr> <td colspan="5"><b>{$stock[company].
{ section name="company" loop=$stock}
<hr noshade size="1" width="100%">
<table width="100%" border="0">
<tr>
<td colspan="5"><b>{$stock[company].symbol}: {$stock[company].name}</b></td>
</tr>
<tr>
{if $stock[company].symbol == "Google"}
<td><b><a href="http://www.nasdaq.com/asp/quotes_multi.asp?mode=stock&symbol=googl">Google - NASDAQ</a></b></td>
{else}
<td> </td>
{/if}
<td colspan="4"><div align="right">{$stock[company].date},
{if $stock[company].time != ""}
{$stock[company].time|date_format:"%I:%M%p"} ET
{/if}
{if $stock[company].status != ""}
- {$stock[company].status}
{/if}</div></td>
</tr>
<tr>
<td>Last Sale:</td>
<td><div align="right"><b>$ {$stock[company].price_last}</b></div></td>
<td> </td>
<td>Net Change:</td>
<td><div align="right">$ {$stock[company].dchangeu}
{if $stock[company].direction == "up"}
<img src="/images/greenArrowSmall.gif" alt="" height="11" width="11" alt="^"> {$stock[company].pchange}%
{else if $stock[company].direction == "down"}
<img src="/images/redArrowSmall.gif" alt="" height="11" width="11" alt="v"> {$stock[company].pchange}%
{/if}
</div></td>
</tr>
<tr>
<td>Today's High:</td>
<td><div align="right">$ {$stock[company].price_max|string_format:"%.2f"}</div></td>
<td> </td>
<td>Today's Low:</td>
<td><div align="right">$ {$stock[company].price_min|string_format:"%.2f"}</div></td>
</tr>
<tr>
<td>Share Volume:</td>
<td><div align="right">{$stock[company].volume}</div></td>
<td> </td>
<td>Previous Close:</td>
<td><div align="right">$ {$stock[company].previous|string_format:"%.2f"}</div></td>
</tr>
<tr>
<td>Best Bid:</td>
{if $stock[company].best_bid != ""}
<td><div align="right">$ {$stock[company].best_bid|string_format:"%.2f"}</div></td>
{else}
<td><div align="right">unavailable</div></td>
{/if}
<td> </td>
<td>Best Ask:</td>
{if $stock[company].best_ask != ""}
<td><div align="right">$ {$stock[company].best_ask|string_format:"%.2f"}</div></td>
{else}
<td><div align="right">unavailable</div></td>
{/if}
</tr>
</table>
{/section}
{section name=“company”loop=$stock}
此代码使用的URL似乎已不存在:
因为它返回一个“未找到”响应
我认为nasdaq不会提供这个.asp页面,因为我读到asp已经很旧了,那么对代码进行最少更改的最佳解决方案是什么呢
我在谷歌上搜索过是否有其他网站提供该asp页面,但没有,只有返回JSON格式数据的API,如果我想更新它以获取JSON变量,这将对我的代码产生很大影响,是否还有其他替代方案
事先非常感谢你 您提供的URL现在可能是。 但我怀疑您真正感兴趣的是填充
$stock
变量
解析json数据实际上非常简单,因此对代码的影响可能没有您想象的那么大。是的,您对新URL的看法是正确的。通过解析JSON数据,我很抱歉,但我不明白你的意思,页面不包含JSON数据(我可能错了),而且我对这个codeigniter框架不太了解,你对此有什么帮助吗?非常感谢你!我的JSON评论不是关于链接页面,而是关于使用返回JSON的API。变量
$stock
是否由旧URL中的数据填充?是的,我没有修改代码中的任何内容。看起来他们只是在某个时候停止使用那个页面。我举了一个例子来说明它以前的样子:这是你的网站显示的还是旧的.asp页面?这就是您获取$stock
数据的页面吗?这就是纳斯达克asp页面以前的样子。这是正确的,这就是$stock变量的填充方式。