Skip to main content

Wikipyedia_md

A python package for converting Wikipedia articles to Markdown format.

Usage

Install the package

pip install wikipyedia-md

Fetch, parse and save a list of articles from urls as .md files in the output dirrectory

from wikipyedia_md import articles_to_markdown

    urls = [
            "https://en.wikipedia.org/wiki/Computer_science",
            # ...
        ]
        articles_to_markdown(urls, output_dir="./articles")

Or you can do it manually

import requests
from wikipyedia_md.html_filtering import filter_html
from wikipyedia_md.wiki_parser import parse_article

urls = [
    "https://en.wikipedia.org/wiki/Computer_science",
    # ...
]

for url in urls:
    response = requests.get(url, timeout=10)
    content = response.text
    modified_html = filter_html(content)
    article = parse_article(modified_html)
    file_name = url.split("/")[-1] + ".md"
    article.save_md(f"{output_dir}/{file_name}")

By default filter_html filters out common html elements that would mess with the markdown output, you can modify the elements if you want by passing a list of elements

from wikipyedia_md import IGNORE_ELEMENTS

custom_elements = IGNORE_ELEMENTS
custom_elements.extend([
    "img",
    # ...
])
modified_html = filter_html(content, filter_elements=custom_elements)

Contributing

Contributions to this package are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.

References

Metadata

Release files for wikipyedia-md 0.1.0

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

Source distribution (sdist)

Source distribution for wikipyedia-md 0.1.0
File Size Uploaded Provenance Actions
wikipyedia_md-0.1.0.tar.gz 3.9 kB Without provenance Details for wikipyedia_md-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wikipyedia-md 0.1.0
File Interpreter ABI Platform Actions
wikipyedia_md-0.1.0-py3-none-any.whl Python 3 none any Details for wikipyedia_md-0.1.0-py3-none-any.whl

Total release size: 9.0 kB

Release files / wikipyedia_md-0.1.0.tar.gz

Download URL wikipyedia_md-0.1.0.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
84f4ce61c744471982053648c4d7b066f7722381cc1b8fac7ab8b834e8b269c1
BLAKE2b-256 checksum
How to use checksums
f7dbc44c045354744034a2a3c88d045a24ac2656baa104bf5a754136b7cab8cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.10.6 Windows/10

Release files / wikipyedia_md-0.1.0-py3-none-any.whl

Download URL wikipyedia_md-0.1.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c939b0683bd84276e785db60bb2d245a763461bf3e308e4809402a0933d4460
BLAKE2b-256 checksum
How to use checksums
4c9f356a6a70ea55c1f5063b6b391a023086b120853d8c90414fc48c7844c083
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.10.6 Windows/10

Security for wikipyedia-md 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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