Wikipedia Python Package
A simple walkthrough of the library functions, showcasing the basic usage of this cool python package.
Import Wikipedia module
# pip install wikipedia
import wikipedia
List the methods using 'dir' function
dir(wikipedia)
Search for any Wiki article using a 'Search query' as an argument
wikipedia.search('Swiss German')
Instantiate a Wikipedia article object with a 'Search query' supplied as an argument
swiss_german = wikipedia.page('Swiss German')
Access the Summary section of the Wiki Article using the '.summary' method
print(swiss_german.summary)
Access the full Content of the Wiki Article using the '.content' method
print(swiss_german.content)
Access the 'Title' of the Wiki Article using the '.title' method
swiss_german.title
Access the 'links' embedded within the Wiki Article using the '.links' method
swiss_german.links
Access the 'References' section of Wiki Article using the '.references' method
swiss_german.references
Access the links to the 'Images' embedded in the Wiki Article using the '.images' method
swiss_german.images
Access the specific section of the wiki Article using the '.section' method by passing the section name as an argument
swiss_german.section('History')
Change language to any supported language on wiki
wikipedia.languages()
wikipedia.set_lang('de')
swiss_german=wikipedia.page('Schweizerdeutsch')
print(swiss_german.summary)