You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
882 B
28 lines
882 B
import wikipedia
|
|
|
|
def najdi_na_wiki(dotaz,jazyk="cs"):
|
|
"""
|
|
Nastaví jazyk a zkusí najít shrnutí dotazu/tématu
|
|
"""
|
|
#Nastavení jazyka (en=angličtina,cs=čestina)
|
|
wikipedia.set_lang(jazyk)
|
|
try:
|
|
vysledek = wikipedia.summary(dotaz,sentences=5)
|
|
return vysledek
|
|
except wikipedia.exceptions.PageError:
|
|
return "Je mi líto, ale stránku se nepodařilo najít"
|
|
except wikipedia.exceptions.DisambiguationError:
|
|
return "je to moc obecné, zkus být konkrétnější"
|
|
|
|
print("--- WIKIPEDIA BOT ---")
|
|
print("Zadej téma, které tě zajíma (např. Python, Praha, Minecraft)")
|
|
while True:
|
|
tema = input("\nHledat (nebo 'konec' pro ukončení):")
|
|
if tema == "konec":
|
|
break
|
|
if tema:
|
|
print("Hledám")
|
|
info = najdi_na_wiki(tema)
|
|
print("-"*30)
|
|
print(info)
|
|
print("-"*30)
|