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.2.tar.gz (43.7 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.2-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hfr_api-0.1.2.tar.gz
  • Upload date:
  • Size: 43.7 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.2.tar.gz
Algorithm Hash digest
SHA256 3788713dc3106ff568bdac33d900b846c0a11ae24fd999a1fcda2a21faad39f0
MD5 0b6f76fb0a4a4c38f32b3a9aaf79a2b2
BLAKE2b-256 7d57af23023bf5ae0badd9320ed5c689e2dd3fe253e97b8be1a524d9f1734482

See more details on using hashes here.

Provenance

The following attestation bundles were made for hfr_api-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: hfr_api-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3af7c392d1b9f23e0f01248e77e22e0334122ea688a8be5daf675e372a6e71cb
MD5 9458009ca202286e3386e86db8f6e6c4
BLAKE2b-256 7bf8ac81e69b207bb0f5a5b54a8430e473d372b98bd14f7f8c906fe1bd6ddc78

See more details on using hashes here.

Provenance

The following attestation bundles were made for hfr_api-0.1.2-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