Skip to main content

Un scraper para obtener los tiempos de juego desde HowLongToBeat.com.

Project description

HowLongToBeat Scraper

A Python package to get game completion times from HowLongToBeat.

This package provides both a command-line tool and a Python API to look up a game and retrieve its estimated times for main story, extras, and 100% completion.

Features

  • Command-Line Interface (CLI): Get game times directly from your terminal.
  • Python API: Easily integrate HowLongToBeat functionality into your own Python scripts.
  • Asynchronous: Built on asyncio and playwright for efficient performance.
  • Structured Data: Returns data in a dataclass for easy access.

Installation

From PyPI (Recommended)

Install the package from the official Python Package Index:

pip install howlongtobeat-scraper

After installation, you may need to install Playwright browsers:

playwright install

From TestPyPI (Development)

For testing purposes, you can also install from TestPyPI:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple howlongtobeat-scraper
playwright install

From Source (for Development)

If you want to contribute or install the latest development version, you can clone the repository and install it in editable mode:

git clone https://github.com/Sermodi/HowLongToBeat_scraper.git
cd HowLongToBeat_scraper
pip install -e .

Usage

Command-Line Interface (CLI)

Once installed, you can use the howlongtobeat command followed by the game's name.

howlongtobeat "The Witcher 3: Wild Hunt"

If the command is not found in your PATH (a common issue on Windows), you can run the package as a module:

python -m howlongtobeat_scraper "The Witcher 3: Wild Hunt"

Example Output:

Searching for "The Witcher 3: Wild Hunt"...
Title: The Witcher 3: Wild Hunt
- Main Story: 51.5 hours
- Main + Extras: 103 hours
- Completionist: 172 hours

Python API

Import the get_game_stats function to use it in your code. It's a synchronous function that internally manages an asyncio event loop for the scraping process.

from __future__ import annotations
from howlongtobeat_scraper.api import get_game_stats, GameData

def main():
    game_name = "Celeste"
    print(f"--- Fetching data for: {game_name} ---")

    try:
        game_data: GameData | None = get_game_stats(game_name)
        if game_data:
            print("API call successful. Data received:")
            print(f"  Title: {game_data.title}")
            print(f"  Main Story: {game_data.main_story} hours")
            print(f"  Main + Extras: {game_data.main_extra} hours")
            print(f"  Completionist: {game_data.completionist} hours")
        else:
            print("No data found for the game.")
    except Exception as e:
        print(f"An error occurred: {e}")

if __name__ == "__main__":
    main()

Spanish Documentation

A Spanish version of this README is available at README.es.md.

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

howlongtobeat_scraper-0.2.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

howlongtobeat_scraper-0.2.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file howlongtobeat_scraper-0.2.1.tar.gz.

File metadata

  • Download URL: howlongtobeat_scraper-0.2.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for howlongtobeat_scraper-0.2.1.tar.gz
Algorithm Hash digest
SHA256 235e2df70df5b6febe5b284aaaead03e82a77cd7b2ef588cc0fd846b686ac92d
MD5 6783421f2b5101bb6bf1ddd893a66c85
BLAKE2b-256 fba7e03e3ef611207e78cd7c79dbdac430a34d80d52a346b110f3a0f967f0784

See more details on using hashes here.

File details

Details for the file howlongtobeat_scraper-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for howlongtobeat_scraper-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c3c5f4c11cbff8e63c4687674c291b3027fabc3d841224dfb307cd2733defef4
MD5 e2ffe8d5e02bc5b432395dcf566374a1
BLAKE2b-256 2614230473403364defea84fcad2e6fcd45060dd14863a5fc9a0b897be398ce0

See more details on using hashes here.

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