$npx -y skills add eph5xx/tweakidea --skill ti-hnparsePython scripts for fetching a single HN post (hnparse.py) and searching HN posts via Algolia (hnsearch.py)
| 1 | Contains two standalone Python scripts that talk to the free Algolia Hacker News API: |
| 2 | |
| 3 | - `hnparse.py` — fetch one HN post (article + full comment tree) and write structured markdown. |
| 4 | - `hnsearch.py` — search/list HN posts by query and time range; emits JSON to stdout. |
| 5 | |
| 6 | ## `hnparse.py` usage |
| 7 | |
| 8 | ```bash |
| 9 | uv run <path-to>/hnparse.py <hn-url-or-id> [-o <output-directory>] |
| 10 | ``` |
| 11 | |
| 12 | - Uses `uv run` inline script metadata for dependencies (playwright, httpx, trafilatura) |
| 13 | - Fetches post metadata and comment tree from Algolia HN API |
| 14 | - Extracts linked article via Playwright headless browser (falls back to plain HTTP) |
| 15 | - Writes `content.md` to the output directory |
| 16 | - Default output: `~/.tweakidea/hn/hn-{item_id}/content.md` |
| 17 | - Prints the absolute path of the output file to stdout (last line) |
| 18 | - All progress messages go to stderr |
| 19 | |
| 20 | For better article extraction from JS-heavy sites, run `uv run playwright install chromium` once. Without it, the script falls back to plain HTTP which works fine for most sites. |
| 21 | |
| 22 | ## `hnsearch.py` usage |
| 23 | |
| 24 | ```bash |
| 25 | uv run <path-to>/hnsearch.py --query "<freeform>" --days <N> \ |
| 26 | [--tags story|show_hn|ask_hn|front_page|poll] \ |
| 27 | [--min-points N] [--limit N] |
| 28 | ``` |
| 29 | |
| 30 | - Single dependency: `httpx` (no Playwright / trafilatura needed) |
| 31 | - Queries `https://hn.algolia.com/api/v1/search` (popularity-sorted) |
| 32 | - `--query` required; `--days` required (`0` = no time filter / all-time) |
| 33 | - `--tags` defaults to `story` (excludes comments); allowed: `story`, `show_hn`, `ask_hn`, `front_page`, `poll`; multiple tags comma-separated |
| 34 | - `--min-points` defaults to `10`; `--limit` defaults to `20` (max `50`) |
| 35 | - Prints a JSON array of hits to **stdout**. Each hit has: `id`, `title`, `url`, `points`, `num_comments`, `author`, `created_at_i`, `relative_age`, `hn_url`. |
| 36 | - Progress and errors go to **stderr**. Exits non-zero on HTTP failure. |