Skip to main content

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

MIT

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

hfr_api-0.1.1.tar.gz (43.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hfr_api-0.1.1-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file hfr_api-0.1.1.tar.gz.

File metadata

  • Download URL: hfr_api-0.1.1.tar.gz
  • Upload date:
  • Size: 43.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hfr_api-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9064608de3b724467265daaa2f46908cfdb5106fbaff9b7829ced15316035f18
MD5 dfeec6f956499a5efd8117b46658d9b5
BLAKE2b-256 fcbcab95fb6d763b616d38db04eac581aa6b05462328f638cccd5467cdeaf75b

See more details on using hashes here.

Provenance

The following attestation bundles were made for hfr_api-0.1.1.tar.gz:

Publisher: publish.yml on dotvav/hfr_api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hfr_api-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: hfr_api-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hfr_api-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1018b52e5456c61e124ff13b312f9373c453a28e33bac16b379ccad1d080c658
MD5 67f80456c9c1f65fc3de0422da561ebe
BLAKE2b-256 1bd2934fc99a51913f974235148729c92f2c63f8cff30cc0c7dff1e169695263

See more details on using hashes here.

Provenance

The following attestation bundles were made for hfr_api-0.1.1-py3-none-any.whl:

Publisher: publish.yml on dotvav/hfr_api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page