Name | dbb-ranking-parser JSON |
Version |
1.0.0
JSON |
| download |
home_page | None |
Summary | Extract league rankings from the DBB (Deutscher Basketball Bund e.V.) website. |
upload_time | 2025-01-07 01:50:34 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT |
keywords |
basketball
rankings
scrape
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
==================
DBB Ranking Parser
==================
Extract league rankings from the DBB_ (Deutscher Basketball Bund e.V.)
website.
This library has been extracted from the web application behind the
website of the `BTB Royals Oldenburg`_ (a basketball team from
Oldenburg, Germany) where it has proven itself for many, many years.
Website
=======
The official micro website is at: https://homework.nwsnet.de/releases/4a51/#dbb-ranking-parser
Code Status
===========
|badge_github-actions_test|
.. |badge_github-actions_test| image:: https://github.com/homeworkprod/dbb-ranking-parser/actions/workflows/test.yml/badge.svg
:alt: Testing Status
:target: https://github.com/homeworkprod/dbb-ranking-parser/actions/workflows/test.yml
Requirements
============
- Python_ 3.9+
- lxml_
Installation
============
Install this package via pip_:
.. code:: sh
$ pip install dbb-ranking-parser
Pre-built binaries (so-called Python "wheels") should be available for
supported Python versions and most architectures.
If not, however, it can be necessary to install a compiler and certain
header files (for the targeted Python_ version as well as those for
libxml2_ and libxslt_) so that lxml can be built from source.
On `Debian Linux`_, one should be able to install these from the
distribution's repositories (as the 'root' user):
.. code:: sh
# aptitude update
# aptitude install build-essential python3.9-dev libxml2-dev libxslt1-dev
Usage
=====
To fetch and parse a league ranking, the appropriate URL is required.
It can be obtained on the DBB_ website. On every league's ranking page
there should be a link to a (non-"XL") HTML print version.
Its target URL should look like this (assuming the league's ID is
12345):
``https://www.basketball-bund.net/public/tabelle.jsp?print=1&viewDescKey=sport.dbb.views.TabellePublicView/index.jsp_&liga_id=12345``
The league ID has to be identified manually in any of the URLs specific
for that league (ranking, schedule, stats).
For convenience, specifying only the league ID is sufficient; the URL
will be assembled automatically. (Obviously, this might break when the
URL structure changes on the DBB website.)
Programmatically
----------------
.. code:: python
from dbbrankingparser import load_ranking_for_league
league_id = 12345
ranking = list(load_ranking_for_league(league_id))
top_team = ranking[0]
print('Top team:', top_team['name'])
The URL can be specified explicitly, too:
.. code:: python
from dbbrankingparser import load_ranking_from_url
URL = '<see example above>'
ranking = list(load_ranking_from_url(URL))
Note that a call to a ``load_ranking_*`` method returns a generator. To
keep its elements around, and also to access them by index, they can be
fed into a list (as shown above).
On the Command Line
-------------------
The package includes a command line script to retrieve a league's
rankings non-programmatically, as JSON. It requires a league ID as its
sole argument:
.. code:: sh
$ dbb-ranking-parser get 12345
[{"name": "Team ACME", "rank": 1, …}]
Via HTTP
--------
Also included is an HTTP wrapper around the parser.
To spin up the server:
.. code:: sh
$ dbb-ranking-parser serve
Listening for HTTP requests on 127.0.0.1:8080 ...
The server will attempt to look up a ranking for requests with an URL
part of the form ``/<league id>``:
.. code:: sh
$ curl http://localhost:8080/12345
[{"name": "Team ACME", "rank": 1, …}]
Docker
======
DBB Ranking Parser can also be run in a Docker_ container. This avoids
the local creation of a virtual environment and the installation of the
packages, or be useful in a deployment where containers are used.
Building a Docker_ image requires:
- Docker_ being installed
- a source copy of the `dbb-ranking-parser` package
In the package path:
.. code:: sh
$ docker build -t dbb-ranking-parser .
This should build a Docker_ image based upon `Alpine Linux`_ and which
includes Python_ 3, lxml_ and the DBB Ranking Parser itself. It should
be roughly 70 MB in size.
Running the Docker container accepts the same arguments as the command
line script.
To fetch a single ranking:
.. code:: sh
$ docker run --rm dbb-ranking-parser get 12345
[{"name": "Team ACME", "rank": 1, …}]
To spin up the HTTP server on port 7000 of the host machine:
.. code:: sh
$ docker run -p 7000:8080 --rm dbb-ranking-parser serve --host 0.0.0.0 --port 8080
The ``--rm`` option causes a container (but not the image) to be removed
after it exits.
.. _DBB: https://www.basketball-bund.net/
.. _BTB Royals Oldenburg: https://www.btbroyals.de/
.. _Python: https://www.python.org/
.. _pip: https://www.pip-installer.org/
.. _lxml: https://lxml.de/
.. _libxml2: https://xmlsoft.org/XSLT/
.. _libxslt: https://xmlsoft.org/XSLT/
.. _Debian Linux: https://www.debian.org/
.. _Docker: https://www.docker.com/
.. _Alpine Linux: https://alpinelinux.org/
Author
======
DBB Ranking Parser was created and is maintained by Jochen Kupperschmidt.
License
=======
Copyright (c) 2006-2025 `Jochen Kupperschmidt
<http://homework.nwsnet.de/>`_
DBB Ranking Parser is licensed under the `MIT License
<https://choosealicense.com/licenses/mit/>`_.
The license text is provided in the `LICENSE <LICENSE>`_ file.
Raw data
{
"_id": null,
"home_page": null,
"name": "dbb-ranking-parser",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "basketball, rankings, scrape",
"author": null,
"author_email": "Jochen Kupperschmidt <homework@nwsnet.de>",
"download_url": "https://files.pythonhosted.org/packages/70/ad/68d15bf6661775f86118eb03d77fd5ddc94f9320ae50dc341da68d7f37a5/dbb_ranking_parser-1.0.0.tar.gz",
"platform": null,
"description": "==================\nDBB Ranking Parser\n==================\n\nExtract league rankings from the DBB_ (Deutscher Basketball Bund e.V.)\nwebsite.\n\nThis library has been extracted from the web application behind the\nwebsite of the `BTB Royals Oldenburg`_ (a basketball team from\nOldenburg, Germany) where it has proven itself for many, many years.\n\n\nWebsite\n=======\n\nThe official micro website is at: https://homework.nwsnet.de/releases/4a51/#dbb-ranking-parser\n\n\nCode Status\n===========\n\n|badge_github-actions_test|\n\n.. |badge_github-actions_test| image:: https://github.com/homeworkprod/dbb-ranking-parser/actions/workflows/test.yml/badge.svg\n :alt: Testing Status\n :target: https://github.com/homeworkprod/dbb-ranking-parser/actions/workflows/test.yml\n\n\nRequirements\n============\n\n- Python_ 3.9+\n- lxml_\n\n\nInstallation\n============\n\nInstall this package via pip_:\n\n.. code:: sh\n\n $ pip install dbb-ranking-parser\n\nPre-built binaries (so-called Python \"wheels\") should be available for\nsupported Python versions and most architectures.\n\nIf not, however, it can be necessary to install a compiler and certain\nheader files (for the targeted Python_ version as well as those for\nlibxml2_ and libxslt_) so that lxml can be built from source.\n\nOn `Debian Linux`_, one should be able to install these from the\ndistribution's repositories (as the 'root' user):\n\n.. code:: sh\n\n # aptitude update\n # aptitude install build-essential python3.9-dev libxml2-dev libxslt1-dev\n\n\nUsage\n=====\n\nTo fetch and parse a league ranking, the appropriate URL is required.\n\nIt can be obtained on the DBB_ website. On every league's ranking page\nthere should be a link to a (non-\"XL\") HTML print version.\n\nIts target URL should look like this (assuming the league's ID is\n12345):\n``https://www.basketball-bund.net/public/tabelle.jsp?print=1&viewDescKey=sport.dbb.views.TabellePublicView/index.jsp_&liga_id=12345``\n\nThe league ID has to be identified manually in any of the URLs specific\nfor that league (ranking, schedule, stats).\n\nFor convenience, specifying only the league ID is sufficient; the URL\nwill be assembled automatically. (Obviously, this might break when the\nURL structure changes on the DBB website.)\n\n\nProgrammatically\n----------------\n\n.. code:: python\n\n from dbbrankingparser import load_ranking_for_league\n\n\n league_id = 12345\n\n ranking = list(load_ranking_for_league(league_id))\n\n top_team = ranking[0]\n print('Top team:', top_team['name'])\n\nThe URL can be specified explicitly, too:\n\n.. code:: python\n\n from dbbrankingparser import load_ranking_from_url\n\n\n URL = '<see example above>'\n\n ranking = list(load_ranking_from_url(URL))\n\nNote that a call to a ``load_ranking_*`` method returns a generator. To\nkeep its elements around, and also to access them by index, they can be\nfed into a list (as shown above).\n\n\nOn the Command Line\n-------------------\n\nThe package includes a command line script to retrieve a league's\nrankings non-programmatically, as JSON. It requires a league ID as its\nsole argument:\n\n.. code:: sh\n\n $ dbb-ranking-parser get 12345\n [{\"name\": \"Team ACME\", \"rank\": 1, \u2026}]\n\n\nVia HTTP\n--------\n\nAlso included is an HTTP wrapper around the parser.\n\nTo spin up the server:\n\n.. code:: sh\n\n $ dbb-ranking-parser serve\n Listening for HTTP requests on 127.0.0.1:8080 ...\n\nThe server will attempt to look up a ranking for requests with an URL\npart of the form ``/<league id>``:\n\n.. code:: sh\n\n $ curl http://localhost:8080/12345\n [{\"name\": \"Team ACME\", \"rank\": 1, \u2026}]\n\n\nDocker\n======\n\nDBB Ranking Parser can also be run in a Docker_ container. This avoids\nthe local creation of a virtual environment and the installation of the\npackages, or be useful in a deployment where containers are used.\n\nBuilding a Docker_ image requires:\n\n- Docker_ being installed\n- a source copy of the `dbb-ranking-parser` package\n\nIn the package path:\n\n.. code:: sh\n\n $ docker build -t dbb-ranking-parser .\n\nThis should build a Docker_ image based upon `Alpine Linux`_ and which\nincludes Python_ 3, lxml_ and the DBB Ranking Parser itself. It should\nbe roughly 70 MB in size.\n\nRunning the Docker container accepts the same arguments as the command\nline script.\n\nTo fetch a single ranking:\n\n.. code:: sh\n\n $ docker run --rm dbb-ranking-parser get 12345\n [{\"name\": \"Team ACME\", \"rank\": 1, \u2026}]\n\nTo spin up the HTTP server on port 7000 of the host machine:\n\n.. code:: sh\n\n $ docker run -p 7000:8080 --rm dbb-ranking-parser serve --host 0.0.0.0 --port 8080\n\nThe ``--rm`` option causes a container (but not the image) to be removed\nafter it exits.\n\n\n.. _DBB: https://www.basketball-bund.net/\n.. _BTB Royals Oldenburg: https://www.btbroyals.de/\n.. _Python: https://www.python.org/\n.. _pip: https://www.pip-installer.org/\n.. _lxml: https://lxml.de/\n.. _libxml2: https://xmlsoft.org/XSLT/\n.. _libxslt: https://xmlsoft.org/XSLT/\n.. _Debian Linux: https://www.debian.org/\n.. _Docker: https://www.docker.com/\n.. _Alpine Linux: https://alpinelinux.org/\n\n\nAuthor\n======\n\nDBB Ranking Parser was created and is maintained by Jochen Kupperschmidt.\n\n\nLicense\n=======\n\nCopyright (c) 2006-2025 `Jochen Kupperschmidt\n<http://homework.nwsnet.de/>`_\n\nDBB Ranking Parser is licensed under the `MIT License\n<https://choosealicense.com/licenses/mit/>`_.\n\nThe license text is provided in the `LICENSE <LICENSE>`_ file.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Extract league rankings from the DBB (Deutscher Basketball Bund e.V.) website.",
"version": "1.0.0",
"project_urls": {
"Changelog": "https://github.com/btb-royals/dbb-ranking-parser/blob/main/CHANGES.rst",
"Repository (GitHub)": "https://github.com/btb-royals/dbb-ranking-parser",
"Repository (Sourcehut)": "https://sr.ht/~homeworkprod/dbb-ranking-parser/",
"Website": "https://homework.nwsnet.de/releases/4a51/#dbb-ranking-parser"
},
"split_keywords": [
"basketball",
" rankings",
" scrape"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "2dc4be781233b2cbacf9a44e64c042ba040fdd7eeb742846ccc9b0fa3b361110",
"md5": "b43c732a8ac181cf32c8bb44cf5714c7",
"sha256": "e0b868baf2caf59077c3771d39f54876ff9cb82a58cf85f9c589cfcfc9d86b4e"
},
"downloads": -1,
"filename": "dbb_ranking_parser-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b43c732a8ac181cf32c8bb44cf5714c7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 10029,
"upload_time": "2025-01-07T01:50:31",
"upload_time_iso_8601": "2025-01-07T01:50:31.469309Z",
"url": "https://files.pythonhosted.org/packages/2d/c4/be781233b2cbacf9a44e64c042ba040fdd7eeb742846ccc9b0fa3b361110/dbb_ranking_parser-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "70ad68d15bf6661775f86118eb03d77fd5ddc94f9320ae50dc341da68d7f37a5",
"md5": "1a4b2ec30f7f70254e4697d956c12cca",
"sha256": "15a0283fb4b72062c7cc0e766c2a609f3dcbe135738da5380bd96b7edbb4ba28"
},
"downloads": -1,
"filename": "dbb_ranking_parser-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "1a4b2ec30f7f70254e4697d956c12cca",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 27296,
"upload_time": "2025-01-07T01:50:34",
"upload_time_iso_8601": "2025-01-07T01:50:34.459766Z",
"url": "https://files.pythonhosted.org/packages/70/ad/68d15bf6661775f86118eb03d77fd5ddc94f9320ae50dc341da68d7f37a5/dbb_ranking_parser-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-07 01:50:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "btb-royals",
"github_project": "dbb-ranking-parser",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "dbb-ranking-parser"
}