Python Wrapper for Wikipedia
Project description
Wikipedia API
This package provides python API for accessing Wikipedia.
Installation
pip3 install wikipedia-api
Usage
import wikipedia
wiki = wikipedia.Wikipedia('en')
page = wiki.article('Python_(programming_language)')
print("Page - Id: %s" % page.id())
# Page - Id: 23862
print("Page - Title: %s" % page.title())
# Page - Title: Python (programming language)
print("Page - Summary: %s" % page.summary())
# Page - Summary: Python is a widely used high-level programming ...
def print_sections(sections, level=0):
for s in sections:
print("%s: %s - %s" % ("*" * (level + 1), s.title(), s.text()[0:40]))
print_sections(s.sections(), level + 1)
print_sections(page.sections())
# *: History - Python was conceived in the late 1980s,
# *: Features and philosophy - Python is a multi-paradigm programming l
# *: Syntax and semantics - Python is meant to be an easily readable
# **: Indentation - Python uses whitespace indentation, rath
# **: Statements and control flow - Python's statements include (among other
# **: Expressions - Some Python expressions are similar to l
# ...
libraries = page.section_by_title('Libraries')
print("Section - Title: %s" % libraries.title())
# Section - Title: Libraries
print("Section - Text: %s" % libraries.text())
# Section - Text: Python's large standard library, commonly cited as ...
External Links
Changelog
0.1.4
It’s possible to extract summary and sections of the page
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Wikipedia-API-0.1.5.tar.gz
(5.0 kB
view hashes)