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.0.tar.gz (43.3 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.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

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

Hashes for hfr_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5c3659974d4011a92019a1883ddb0e14ead34331ecf834d20f07ae6dbd26d424
MD5 bbdf447ae700e40570b4a7dbbb672103
BLAKE2b-256 3af216038e82318053c50924b7ad23d30706314d8e6267f08143510f523e9f97

See more details on using hashes here.

Provenance

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

Hashes for hfr_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93720332ee8ce1a39946b921bb531efc8f00a43770b36392f55bed74215c5ddf
MD5 3b0b4aff1c891a65dcb47b191202e56f
BLAKE2b-256 ce4221070f7f9b81057b4b01e908302578900a1e23fa61053fad00b3ee3615db

See more details on using hashes here.

Provenance

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