We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7a8f418 commit 44648dfCopy full SHA for 44648df
1 file changed
wiki_search.py
@@ -0,0 +1,22 @@
1
+import wikipedia
2
+import webbrowser
3
+
4
+topic = input("Enter a topic to search: ")
5
6
+try:
7
+ # Get summary
8
+ summary = wikipedia.summary(topic, sentences=4)
9
+ print("\nResult:\n")
10
+ print(summary)
11
12
+ # Ask if user wants full page
13
+ choice = input("\nDo you want to open the full Wikipedia page? (yes/no): ").lower()
14
+ if choice == "yes":
15
+ page = wikipedia.page(topic)
16
+ webbrowser.open(page.url)
17
18
+except wikipedia.exceptions.DisambiguationError as e:
19
+ print("Your search was too broad.")
20
+ # print(e.options)
21
+except wikipedia.exceptions.PageError:
22
+ print("No page found for that topic.")
0 commit comments