Skip to content

Instantly share code, notes, and snippets.

@AliYmn
Last active January 28, 2017 15:36
Show Gist options
  • Save AliYmn/5767c27570c75cbb6e048866feab9442 to your computer and use it in GitHub Desktop.
Save AliYmn/5767c27570c75cbb6e048866feab9442 to your computer and use it in GitHub Desktop.
import wikipedia
wikipedia.set_lang("tr")
file = open("aranacaklar.txt", "r" , encoding="utf-8")
line = file.readlines()
words = line
for word in words:
print(word,' Aranıyor ...')
#kelimeleri ara
topics = wikipedia.search(word)
for i in topics:
if(wikipedia.exceptions.DisambiguationError):
try:
print(wikipedia.summary(topics[topics.index(i)+1]), file=open(i + ".txt", mode="w", encoding="utf-8"))
except IndexError or wikipedia.exceptions.PageError:
pass
else:
try:
print(wikipedia.summary(topics[topics.index(i)]), file=open(i + ".txt", mode="w", encoding="utf-8"))
except IndexError or wikipedia.exceptions.PageError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment