Skip to content

Instantly share code, notes, and snippets.

@AliYmn
Last active January 28, 2017 15:35
Show Gist options
  • Save AliYmn/a42bfa6215f3b204f692d46b7e6dcd58 to your computer and use it in GitHub Desktop.
Save AliYmn/a42bfa6215f3b204f692d46b7e6dcd58 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
count = 0
for word in words:
print(word,' aranıyor ...')
#kelimeleri ara
topics = wikipedia.search(word)
for i in topics:
count = count+1
if(wikipedia.exceptions.DisambiguationError):
try:
print(wikipedia.page(topics[topics.index(i)+1]).title,"\n",wikipedia.summary(topics[topics.index(i)+1]), file=open(str(count) + ".txt", mode="w", encoding="utf-8"))
except IndexError or wikipedia.exceptions.PageError:
pass
else:
try:
print(wikipedia.page(topics[topics.index(i)]).title,"\n",wikipedia.summary(topics[topics.index(i)+1]), file=open(str(count) + ".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