本程式以 Playwright 製作,可以自動下載每日台股資料,包含:
- 每日上市收盤價
- 每日上櫃收盤價
- 每日上市買賣超
- 每日上櫃買賣超
- 於週六、日可再下載該週大股東持股資料
-
安裝 Node.js 及 Playwright
- Node.js 安裝指南
- 安裝 Playwright:
npm install playwright
-
執行程式
- 直接執行
app.js
,程式將會自動建立所需的資料夾並下載資料 - 或也可自行打包
- 直接執行
- Node.js
- Playwright
- 連結到每個網頁時,目前使用 page.waitForTimeout() 的方式等待網頁讀取完才繼續下一步動作。考量使用者的網路連線品質不一,超過等待的時間頁面可能尚未讀取完畢,導致程式無法順路執行。
Roan,專長是碎碎念。
Built with Playwright, this code automatically downloads daily Taiwan stock data, including:
- Daily closing prices for listed stocks
- Daily closing prices for OTC stocks
- Daily buy/sell surplus for listed stocks
- Daily buy/sell surplus for OTC stocks
- On weekends, it also downloads the major shareholders' holdings for the week
-
Install Node.js and Playwright
- Node.js Installation Guide
- Install Playwright:
npm install playwright
-
Run the code
- Directly run
app.js
, and it will automatically create the necessary folders and download the data.
- Directly run
- Node.js
- Playwright
- The code uses
page.waitForTimeout()
to wait for the web page to load before proceeding to the next step. Due to varying internet connection qualities among users, there might be instances where the page has not fully loaded after the wait time, causing the code to not run smoothly. A more robust waiting mechanism in future improvements is considered.
Roan