DEV Community

Moumen
Moumen

Posted on • Edited on

Wikipedia Python Tutorial

# Created By Moumen
import wikipedia
import json
import time
# Created By Moumen
print(f"Welcome To Wikipedia")
lan = input (str("Language: "))
test_file = open("log.txt", "w")
# Created By Moumen
while True: 
    question = input("Question: ")
    wikipedia.set_lang(lan)
    question_1 = question.replace("What is", "")
# Created By Moumen

    test_file = open("log.txt", "a")
    test_file.write(f"\n {question_1}") 
    test_file.close()
    answer_1 = question.replace("What is", "")
    search = wikipedia.page(answer_1)
    info = search.content
# Created By Moumen
    new_file = open(f"{answer_1}.txt", "w")
    new_file.write(info)
    print("✅")
# Created By Moumen
Enter fullscreen mode Exit fullscreen mode

Top comments (0)