Skip to main content

Consume Wikivoyage pages into pure (elegant) Markdown. Probably.

Project description

wikivoyage

Consume Wikivoyage into pure (elegant) Markdown. Probably.

$ pip install wikivoyage

Usage

Just do what you want.

import wikivoyage

# Learn about the States
res = wikivoyage.get("https://en.wikivoyage.org/wiki/United_States_of_America")
print(res)
WikivoyageSections(
    url='https://en.wikivoyag…',
    sections=[
        Section(
            title='United States of America', 
            content='The **United States of America** spans a continent…'
        ), 
        Section(
            title='Regions', 
            content="Wikivoyage organizes the 50 states and the nation'…"
        ), 
        Section(
            title='Cities', 
            content='The following is a list of nine of the most notabl…'
        ),
        ...
    ]
)

Super simple.

Why?

I'm initially an "i-aint-reading-allat" person, thus I made this project so I can better categorize all the sections from a Wikivoyage page, feed it to an LLM and summarize it for me.

Check out where-next, a Next.JS project created by me to learn more.

API Reference

The juicy API reference. Press CTRL + F to search for what you need or type directly in the search bar if you're on mobile.

def get()

get(url: str, **requests_kwargs) -> WikivoyageSections

Fetches a Wikivoyage page and parses it into Markdown.

Args:

  • url (str): The URL.
  • **requests_kwargs: Keyword-only arguments to pass into requests.get.

Returns:
WikivoyageSections: Wikivoyage sections.

dataclass WikivoyageSections

Represents all the Wikivoyage sections. (manually-created)

class WikivoyageSections:
    url: str  # The request URL
    sections: List[Section]  # Sections

dataclass Section

Repersents a Wikivoyage section. (manually-created)

class Section:
    title: str  # The title. Alias: `section`
    content: str  # The content. Alias: `markdown`

Contributing

Contributions are welcome! And yes, I'm not really familiar with GitHub so please help me.

License

MIT License.

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

wikivoyage-0.2.tar.gz (5.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page