COCO研究院

 找回密碼
 註冊
搜索
查看: 1042|回復: 1

python 爬取即時股價

[複製鏈接]
發表於 23-7-16 18:25 | 顯示全部樓層 |閱讀模式
本帖最後由 綠茶妹 於 23-7-16 18:33 編輯


python 爬取即時股價

資料來源
https://mis.twse.com.tw/stock/index.jsp


這個很簡單,也非常實用
  1. import requests

  2. url = "https://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=tse_2330.tw"
  3. res = requests.get(url)
  4. res.json()

  5. print(res.json())
複製代碼


  1. D:\93-greentea-python\stock\01-draw-line>python getRealtimeStock.py
  2. {'msgArray': [{'tv': '6401', 'ps': '6401', 'pz': '591.0000', 'bp': '0', 'fv': '62', 'oa': '589.0000', 'ob': '588.0000', 'a': '591.0000_592.0000_593.0000_594.0000_595.0000_', 'b': '590.0000_589.0000_588.0000_587.0000_586.0000_', 'c': '2330', 'd': '20230714', 'ch': '2330.tw', 'ot': '14:30:00', 'tlong': '1689316200000', 'f': '1616_3220_1429_969_1269_', 'ip': '0', 'g': '156_25_316_978_950_', 'mt': '000000', 'ov': '43873', 'h': '591.0000', 'i': '24', 'it': '12', 'oz': '589.0000', 'l': '587.0000', 'n': '台積電', 'o': '589.0000', 'p': '0', 'ex': 'tse', 's': '6401', 't': '13:30:00', 'u': '643.0000', 'v': '23016', 'w': '527.0000', 'nf': '台灣積體電路製造股份有限公司', 'y': '585.0000', 'z': '591.0000', 'ts': '0'}], 'referer': '', 'userDelay': 5000, 'rtcode': '0000', 'queryTime': {'sysDate': '20230716', 'stockInfoItem': 1897, 'stockInfo': 104196, 'sessionStr': 'UserSession', 'sysTime': '18:20:31', 'showChart': False, 'sessionFromTime': -1, 'sessionLatestTime': -1}, 'rtmessage': 'OK', 'exKey': 'if_tse_2330.tw_zh-tw.null', 'cachedAlive': 202229}

  3. D:\93-greentea-python\stock\01-draw-line>
複製代碼



參考資料
https://kbwen.com/2020/09/08/pyt ... %E8%82%A1%E5%83%B9/


評分

參與人數 2金錢 +4 收起 理由
stock888 + 2 按一個讚
manmanlai + 2 感謝分享

查看全部評分

 樓主| 發表於 23-7-16 18:31 | 顯示全部樓層
這個影片感覺也滿好用的


【Python股市爬蟲 第4集】台股即時成交行情下載|盤中即時分析必學!


評分

參與人數 1金錢 +2 收起 理由
manmanlai + 2 很棒的文章,感恩

查看全部評分

您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-5-2 10:10

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 | AI繪圖AI超擬真美女AI beauty AI Stable DiffusionAI正妹AI Lookbook