Skip to content
This repository was archived by the owner on Oct 4, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Mini_projects/Wikipedia bot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Wikipedia bot in Python #

👋 Hi there!

## About the project ##

This is a simple Wikipedia surfing bot in Python made with the wikipedia library. It allows the user to search for a topic and choose between the articles related to it. Once the user has chosen the article, it provides the link to the article and summarizes it in a line.

## Installation and use ##

1) Install the dependency

```pip3 install wikipedia```

2) Run the application

```python3 Wikipedia_bot.py```

3) Happy learning!

## Bugs and improvements ###

1) When trying to load the page of some articles, the program encounters a disambiguation error that suggests some other(totally unrelated) articles. I can't seem to fix it(found a workaround tho). Any help is appreciated!

2) This app could definitely use a GUI

19 changes: 19 additions & 0 deletions Mini_projects/Wikipedia bot/Wikipedia_bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import wikipedia as wiki # Import the library

topic = input("Please enter the topic: ")
results = wiki.search(topic) # Search for related articles
print("[+] Found", len(results), "entries!")
print("Select the article: ")
for index, value in enumerate(results): # Give the user an opportunity to choose between the articles
print(str(index)+ ")"+" "+str(value))

print("\n")
article = int(input())
try: # Try retrieving info from the Wiki page
page = wiki.page(results[article])
print(str(page.title).center(1000))
print(page.url)
print(wiki.summary(results[article], sentences=1))
except DisambiguationError as e: # Workaround for the disambiguation error
print("[-] An error occured!")
print("URL: "+"https://en.wikipedia.org/wiki/"+str(results[article]).replace(' ', '_'))
19 changes: 19 additions & 0 deletions Python/Wikipedia_bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import wikipedia as wiki

topic = input("Please enter the topic: ")
results = wiki.search(topic)
print("[+] Found", len(results), "entries!")
print("Select the article: ")
for index, value in enumerate(results):
print(str(index)+ ")"+" "+str(value))

print("\n")
article = int(input())
try:
page = wiki.page(results[article])
print(str(page.title).center(1000))
print(page.url)
print(wiki.summary(results[article], sentences=1))
except DisambiguationError as e:
print("[-] An error occured!")
print("URL: "+"https://en.wikipedia.org/wiki/"+str(results[article]).replace(' ', '_'))