1.3 KiB
1.3 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Overview
This is a single-file Python CLI (cpc_price.py) that scrapes Taiwan CPC's (中油) historical fuel price page and outputs the data in various formats.
Running the Script
python3 cpc_price.py # table output (default)
python3 cpc_price.py --ad # convert ROC dates to AD
python3 cpc_price.py --latest # show only the most recent record
python3 cpc_price.py -f csv # CSV output
python3 cpc_price.py -f json --ad # JSON output with AD dates
Dependencies
pip install requests beautifulsoup4
Key Notes
- SSL: The CPC website has a certificate missing a Subject Key Identifier, so
verify=Falseis used withurllib3warnings suppressed. - Date format: The site uses ROC (Republic of China) calendar dates (e.g.
115/03/16). The--adflag converts them by adding 1911 to the year. - Data source:
https://www.cpc.com.tw/historyprice.aspx?n=2890— shows roughly the last 7 weekly price adjustments. - Parsing: The page has a single
<table>with headers in the first<tr>. If the site restructures its HTML, thefetch_prices()function is the place to fix parsing.