Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Chatbot/Wikipedia.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
41 lines (28 sloc)
1014 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This whole code was copied from https://www.thepythoncode.com/article/access-wikipedia-python?fbclid=IwAR0oEeD19gpwYc99fvv0bPkWOHHZOP1Hk_j8JMw0J07Z6taDBGhRiZJ8uZ8 | |
import wikipedia | |
# print the summary of what python is | |
print(wikipedia.summary("Python Programming Language")) | |
# search for a term | |
result = wikipedia.search("Neural networks") | |
print("Result search of 'Neaural networks':", result) | |
#get the page: Neural network | |
page = wikipedia.page(result[0]) | |
# get the title of the page | |
title = page.title | |
# get the categories of the page | |
categories = page.categories | |
# get the whole wikipedia page text (content) | |
content = page.content | |
#get all the links in the page | |
links = page.links | |
# get the page references | |
references = page.references | |
#summary | |
summary = page.summary | |
# print info | |
print("Page content:\n", content, "\n") | |
print("Page title:", title, "\n") | |
print("Categories:", categories, "\n") | |
print("Links:", links, "\n") | |
print("References:", references, "\n") | |
print("Summary:", summary, "\n") | |