Add README.md
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
34
README.md
Normal file
34
README.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# cpc-price-cli
|
||||
|
||||
查詢台灣中油(CPC)歷史油價的命令列工具,資料來源為[中油歷史油價頁面](https://www.cpc.com.tw/historyprice.aspx?n=2890),顯示近期約 7 筆每週調價紀錄。
|
||||
|
||||
## 安裝依賴
|
||||
|
||||
```bash
|
||||
pip install requests beautifulsoup4
|
||||
```
|
||||
|
||||
## 使用方式
|
||||
|
||||
```bash
|
||||
python3 cpc_price.py # 表格輸出(預設)
|
||||
python3 cpc_price.py --latest # 只顯示最新一筆
|
||||
python3 cpc_price.py --ad # 日期轉西元年
|
||||
python3 cpc_price.py -f csv # CSV 輸出
|
||||
python3 cpc_price.py -f json # JSON 輸出
|
||||
python3 cpc_price.py -f json --ad # JSON + 西元年
|
||||
```
|
||||
|
||||
## 參數說明
|
||||
|
||||
| 參數 | 說明 |
|
||||
|------|------|
|
||||
| `-f`, `--format` | 輸出格式:`table`(預設)、`csv`、`json` |
|
||||
| `--ad` | 將民國年份轉換為西元年份(民國年 + 1911) |
|
||||
| `--latest` | 只顯示最新一筆資料 |
|
||||
|
||||
## 注意事項
|
||||
|
||||
- 中油網站的 SSL 憑證缺少 Subject Key Identifier,因此使用 `verify=False` 略過驗證。
|
||||
- 日期格式為民國年,例如 `115/03/16`,加上 `--ad` 後顯示為 `2026/03/16`。
|
||||
- 若頁面 HTML 結構變動導致解析失敗,請檢查 `fetch_prices()` 函式。
|
||||
Reference in New Issue
Block a user