-2
你好这个问题具有相似性this post:PHP获取谷歌财务数据
但不幸的是,这不是用PHP工作。
header('charset=utf8');
$rr=file_get_contents("https://www.google.com/finance/info?q=NSE:TCS");
$json = json_decode($rr, true);
echo '<pre>' . print_r($json, true) . '</pre>';
这只显示空白。没有数据。
仅使用file_get_contents给出了类似的内容。
// [ { "id": "784961" ,"t" : "TCS" ,"e" : "NSE" ,"l" : "2,437.00" ,"l_fix" :
"2437.00" ,"l_cur" : "₹2,437.00" ,"s": "0" ,"ltt":"3:49PM GMT+5:30" ,"lt" :
"Jul 20, 3:49PM GMT+5:30" ,"lt_dts" : "2017-07-20T15:49:12Z" ,"c" : "-12.60"
,"c_fix" : "-12.60" ,"cp" : "-0.51" ,"cp_fix" : "-0.51" ,"ccol" : "chr"
,"pcls_fix" : "2449.6" } ]
如果json_decode不起作用,那么我有什么选择以其他方式做到这一点。 我会以表格格式或每个份额显示数据。
full quote link
http://www.google.com/finance/info?infotype=infoquoteall&q=NSE:TCS"
我是有在 “//” 风格:)同样的想法。如何访问个人领域?例如,股票报价“l” – mimi
我试过这样做echo $ arr [0] - > l;我得到错误未定义变量:arr,试图获取非对象2错误的属性。 – mimi
@imimi上面的例子应该是'$ json [0] - > l' –