A Python library to interface with forum.hardware.fr
Project description
HFR API
A Python library to interface with forum.hardware.fr.
Installation
You can install the package using pip:
pip install hfr-api
Usage
Browsing a Category
You can browse topics in a specific category.
from hfr import Category
# Initialize a category (e.g., category 13 for "Discussions")
# See hfr/category.py for a mapping of category IDs
category = Category(13)
# Load the first page of topics
category.load_page(1)
# Iterate through the topics found on that page
for topic in category.topics:
print(f"Topic ID: {topic.post}, Sticky: {topic.sticky}")
# Note: Topic title is not available until the topic itself is loaded
Reading a Topic
You can access messages within a topic.
from hfr import Topic
# Initialize a topic with: Category ID, Subcategory ID, Post ID
topic = Topic(cat=13, subcat=432, post=73768)
# Load the first page of the topic
topic.load_page(1)
print(f"Title: {topic.title}")
# Iterate through messages
# Messages are grouped by date (YYYY-MM-DD)
for date_str, messages_dict in topic.messages.items():
print(f"--- Date: {date_str} ---")
for msg_id, message in messages_dict.items():
print(f"[{message.posted_at}] {message.author}:")
print(message.text)
print("-" * 20)
CLI
The package includes a command-line interface to interact with the forum.
Installation
You can install the CLI tool using uv or pipx:
uv tool install hfr-api
# or
pipx install hfr-api
Once installed, the hfr command will be available in your path.
Get Topic Info
Retrieve metadata about a topic as JSON.
hfr info <cat> <subcat> <post>
# Example
hfr info 13 432 73768
Dump Topic Content
Dump all messages from a topic (or a specific page) to JSON.
hfr dump <cat> <subcat> <post> <output_file> [--page <page_number>]
# Example: Dump all pages to a file
hfr dump 13 432 73768 my_topic.json
# Example: Dump all pages to stdout
hfr dump 13 432 73768 - > my_topic.json
# Example: Dump only page 1 to a file
hfr dump 13 432 73768 page1.json --page 1
Features
- Categories: List topics within a forum category.
- Topics: Read messages, retrieve metadata (page count, dates).
- Messages: Parse content including BBCode strings.
- Parsers: Handles HTML parsing from the forum.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Project details
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 hfr_api-0.1.0.tar.gz.
File metadata
- Download URL: hfr_api-0.1.0.tar.gz
- Upload date:
- Size: 43.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c3659974d4011a92019a1883ddb0e14ead34331ecf834d20f07ae6dbd26d424
|
|
| MD5 |
bbdf447ae700e40570b4a7dbbb672103
|
|
| BLAKE2b-256 |
3af216038e82318053c50924b7ad23d30706314d8e6267f08143510f523e9f97
|
Provenance
The following attestation bundles were made for hfr_api-0.1.0.tar.gz:
Publisher:
publish.yml on dotvav/hfr_api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hfr_api-0.1.0.tar.gz -
Subject digest:
5c3659974d4011a92019a1883ddb0e14ead34331ecf834d20f07ae6dbd26d424 - Sigstore transparency entry: 1573374136
- Sigstore integration time:
-
Permalink:
dotvav/hfr_api@a537bcd0d0445c3c2d9ccafdc7b85b6f11983a2c -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/dotvav
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a537bcd0d0445c3c2d9ccafdc7b85b6f11983a2c -
Trigger Event:
release
-
Statement type:
File details
Details for the file hfr_api-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hfr_api-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93720332ee8ce1a39946b921bb531efc8f00a43770b36392f55bed74215c5ddf
|
|
| MD5 |
3b0b4aff1c891a65dcb47b191202e56f
|
|
| BLAKE2b-256 |
ce4221070f7f9b81057b4b01e908302578900a1e23fa61053fad00b3ee3615db
|
Provenance
The following attestation bundles were made for hfr_api-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on dotvav/hfr_api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hfr_api-0.1.0-py3-none-any.whl -
Subject digest:
93720332ee8ce1a39946b921bb531efc8f00a43770b36392f55bed74215c5ddf - Sigstore transparency entry: 1573374172
- Sigstore integration time:
-
Permalink:
dotvav/hfr_api@a537bcd0d0445c3c2d9ccafdc7b85b6f11983a2c -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/dotvav
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a537bcd0d0445c3c2d9ccafdc7b85b6f11983a2c -
Trigger Event:
release
-
Statement type: