Initial commit: CPC fuel price CLI scraper
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
30
CLAUDE.md
Normal file
30
CLAUDE.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# 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
|
||||
|
||||
```bash
|
||||
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
|
||||
|
||||
```bash
|
||||
pip install requests beautifulsoup4
|
||||
```
|
||||
|
||||
## Key Notes
|
||||
|
||||
- **SSL**: The CPC website has a certificate missing a Subject Key Identifier, so `verify=False` is used with `urllib3` warnings suppressed.
|
||||
- **Date format**: The site uses ROC (Republic of China) calendar dates (e.g. `115/03/16`). The `--ad` flag 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, the `fetch_prices()` function is the place to fix parsing.
|
||||
Reference in New Issue
Block a user