看板 PHP 關於我們 聯絡資訊
乳提 小弟想要抓取 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資料這一端就出現問題 還是語法有誤嗎? 第一次發文 如果有不妥或排版不佳請見諒 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.238.38.75 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1612882953.A.5D4.html
jh961202: allow_url_file_open的設定值是? 02/09 23:59
uncle925: 拍謝解決了 漏看了陣列 $data['msgArray'][0]['c'] 可以 02/10 13:10
laechan: 用 file_get_contents 會受限於對方端是否把資料源公開 02/17 11:45