Hacker News CLI client
Project description
hn-news — Hacker News CLI client
Technical summary
hn-news is a small CLI and library that scrapes the Hacker News front page and prints the top headlines in a tidy, Rich-formatted list. It focuses on reliability and clear error handling (uses httpx, beautifulsoup4, and rich). The command-line entry point is provided as hn-news and the programmatic API exposes HeadlineFetcher for direct use in other Python code.
Key behaviors
- Fetches and parses the Hacker News front page at
https://news.ycombinator.com. - Returns headlines as a list of
(title, url)tuples. Relative links likeitem?id=...are normalized to absolute URLs. - CLI options: configure number of headlines (
-n/--number) and enable debug logging (--debug). - Uses structured logging via
rich.logging.RichHandlerand prints errors to the console on failure.
Requirements
- Python: >=3.12 (declared in
pyproject.toml). - Python packages:
httpx,beautifulsoup4,rich(these are declared as project dependencies).
Installation
Install from source (recommended for development):
python -m pip install --upgrade pip
python -m pip install .
Or install from a built wheel (after running a build):
python -m pip install dist/hn-news-<version>-py3-none-any.whl
Usage — CLI
Show top 5 headlines (default):
hn-news
Show 10 headlines:
hn-news -n 10
Enable debug logging to see HTTP/parse debug messages:
hn-news --debug
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hn_news-0.1.0.tar.gz.
File metadata
- Download URL: hn_news-0.1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbc2ff550776a4c92c81d78b9673ab52a8840d7bef7fc0a0c88f5752201c73ac
|
|
| MD5 |
0fe1dedf18826c4f9d4ab230fbb1f557
|
|
| BLAKE2b-256 |
48c4246028a948814884739ef0581b65c70252c28c91e70af25dfd01e97c5e03
|
File details
Details for the file hn_news-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hn_news-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fca289e918cb1be3831500c746f48c2726cf0aed1d645a9e2451b02815f868b8
|
|
| MD5 |
de77fc36df7194b4fbab27ddb393c9a8
|
|
| BLAKE2b-256 |
5aae6f5fc3e75b45251f46572eb1de7717b161ad460dc54fcc39a72f5710f9bd
|