Created
June 21, 2020 18:39
-
-
Save YannBouyeron/d85f4cd3c3c9cdaffdf447f11d06c7a6 to your computer and use it in GitHub Desktop.
Wikipedia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.6 | |
import wikipedia | |
import argparse | |
def searcher(x): | |
print("\n") | |
print("="*30 + " WIKIPEDIA " + "="*30) | |
print("\n") | |
print("\n") | |
result = wikipedia.search(x) | |
print("Result search of {0}: ".format(x), result) | |
print("\n") | |
page = wikipedia.page(result[0]) | |
title = page.title | |
categories = page.categories | |
content = page.content | |
links = page.links | |
references = page.references | |
summary = page.summary | |
print("Page content:\n", content, "\n") | |
print("Page title:", title, "\n") | |
print("Categories:", categories, "\n") | |
print("Links:", links, "\n") | |
print("References:", references, "\n") | |
print("Summary:", summary, "\n") | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description="Wikipedia") | |
parser.add_argument("search", help="Search on Wikipedia") | |
parser.add_argument("-l", "--lang", help="Change language") | |
args = parser.parse_args() | |
search, lang = args.search, args.lang | |
if args.lang: | |
wikipedia.set_lang(args.lang) | |
searcher(search) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Creat executable :
Use:
Or for french Wikipedia: