[請益] 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