[请益] php爬台股即时股价问题

楼主: uncle925 (-新潮x乐活x便捷)   2021-02-09 23:02:30
乳提 小弟想要抓取
https://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=tse_2330.tw&
收盘价
function get_Stock_price(){
$url =
"https://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=tse_2330.tw";
$data = file_get_contents($url);
$data = json_decode($data,true);
echo $data['msgArray']['c'];
}
却怎么试都抓不到资料,会是在get资料这一端就出现问题
还是语法有误吗?
第一次发文 如果有不妥或排版不佳请见谅
作者: jh961202 (阿电)   2021-02-09 23:59:00
allow_url_file_open的设定值是?
楼主: uncle925 (-新潮x乐活x便捷)   2021-02-10 13:10:00
拍谢解决了 漏看了阵列 $data['msgArray'][0]['c'] 可以
作者: laechan (挥泪斩马云)   2021-02-17 11:45:00
用 file_get_contents 会受限于对方端是否把资料源公开

Links booklink

Contact Us: admin [ a t ] ucptt.com