Skip to main content

toolwiki

This is a python library to extract information from Wikipedia pages.

Contents

  • tables.py module includes function to extract information from a wikipedia table as a pandas dataframe.
  • pages.py module includes:
    • function to extract inferred gender based on the ratio of male and female pronouns on a wikipedia page.
    • function to get all category members.

Installation

You can install toolwiki package from PyPI:

python -m pip install toolwiki

toolwiki is supported on Python 3.7 and above.

How to use

You can use this package in your own Python code by importing from the toolwiki package:

>>> from toolwiki import tables
>>> dfs= tables.get_dataframes(url='https://en.wikipedia.org/wiki/List_of_UFC_events', by_class='wikitable', table_indices= [], raw=False)
>>> dfs
[                                         Event  ...  Ref.
1                                      UFC 276  ...   [9]
2                          UFC Fight Night 211  ...  [10]
..   ...                                         ...  ...        ...    ...
14                         UFC Fight Night 202  ...  [20]
15            UFC Fight Night: Walker vs. Hill  ...  [21]
[15 rows x 5 columns],        #                                       Event  ... Attendance   Ref.
1    593          UFC 271: Adesanya vs. Whittaker II  ...     17,872   [22]
2    592  UFC Fight Night: Hermansson vs. Strickland  ...        N/A   [23]
..   ...                                         ...  ...        ...    ...
601  002                           UFC 2: No Way Out  ...      2,000  [558]
602  001                        UFC 1: The Beginning  ...      7,800  [559]
[602 rows x 7 columns]]


>>> from toolwiki import page
>>> page.get_gender('https://en.wikipedia.org/wiki/Karolina_Kowalkiewicz', gender_threshold=0.8)
('female', '1.0')

>>> from toolwiki import page
>>> page.get_category_members('https://en.wikipedia.org/wiki/Category:Leadership', type=['pages', 'subcategories'])
           category           type                                   title                                           url
0   Category:Leadership          pages                              Leadership                              /wiki/Leadership
1   Category:Leadership          pages                                3C-model                                /wiki/3C-model
2   Category:Leadership          pages  African Nutrition Leadership Programme  /wiki/African_Nutrition_Leadership_Programme
3   Category:Leadership          pages                      Agentic leadership                      /wiki/Agentic_leadership
4   Category:Leadership          pages                        Agile leadership                        /wiki/Agile_leadership
..                  ...            ...                                     ...                                           ...
78  Category:Leadership  subcategories                     Leadership scholars            /wiki/Category:Leadership_scholars
79  Category:Leadership  subcategories                      Leadership studies             /wiki/Category:Leadership_studies
80  Category:Leadership  subcategories                              Management                     /wiki/Category:Management
81  Category:Leadership  subcategories                  Positions of authority         /wiki/Category:Positions_of_authority
82  Category:Leadership  subcategories                     Leadership training            /wiki/Category:Leadership_training

[83 rows x 4 columns]

Metadata

Release files for toolwiki 0.1.18

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for toolwiki 0.1.18
File Size Uploaded Provenance Actions
toolwiki-0.1.18.tar.gz 6.6 kB Without provenance Details for toolwiki-0.1.18.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for toolwiki 0.1.18
File Interpreter ABI Platform Actions
toolwiki-0.1.18-py3-none-any.whl Python 3 none any Details for toolwiki-0.1.18-py3-none-any.whl

Total release size: 13.8 kB

Release files / toolwiki-0.1.18.tar.gz

Download URL toolwiki-0.1.18.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2d2cd7fa468568395717150f4afe57f68156196189ab97a6f0cfbf6301888407
BLAKE2b-256 checksum
How to use checksums
78267e54ef3ac792233d95f1e59cd5094c506739e7ea3b8b9ae6110888e71935
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

Release files / toolwiki-0.1.18-py3-none-any.whl

Download URL toolwiki-0.1.18-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
758efaf1eee1f541d30d084d1364a8ac2f542eae148623b388453e9c92650ff9
BLAKE2b-256 checksum
How to use checksums
883038ebc313f8d9cffaa6f1f289523ac7a75a358c17a201baa9b7f3fc35f368
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

Security for toolwiki 0.1.18

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page