Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Wikipedia Module #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 15, 2017
Merged
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
86 changes: 86 additions & 0 deletions WikipediaModule
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"""
Created on Sat Jul 15 01:41:31 2017

@author: Albert
"""
import wikipedia as wk
from bs4 import BeautifulSoup

def wiki():
'''
Search Anything in wikipedia
'''

word=raw_input("Wikipedia Search : ")
results=wk.search(word)
for i in enumerate(results):
print i
try:
key=input("Enter the number : ")
except AssertionError:
key=input("Please enter corresponding article number : ")

page=wk.page(results[key])
url=page.url
#originalTitle=page.original_title
pageId=page.pageid
#references=page.references
title=page.title
#soup=BeautifulSoup(page.content,'lxml')
pageLength=input('''Wiki Page Type : 1.Full 2.Summary : ''')
if pageLength==1:
soup=fullPage(page)
print soup
else:
print title
print "Page Id = ",pageId
print page.summary
print "Page Link = ",url
#print "References : ",references


pass

def fullPage(page):
soup=BeautifulSoup(page.content,'lxml')
return soup

def randomWiki():
'''
This function gives you a list of n number of random articles
Choose any article.
'''
number=input("No: of Random Pages : ")
lst=wk.random(number)
for i in enumerate(lst):
print i
try:
key=input("Enter the number : ")
assert key>=0 and key<number
except AssertionError:
key=input("Please enter corresponding article number : ")

page=wk.page(lst[key])
url=page.url
#originalTitle=page.original_title
pageId=page.pageid
#references=page.references
title=page.title
#soup=BeautifulSoup(page.content,'lxml')
pageLength=input('''Wiki Page Type : 1.Full 2.Summary : ''')
if pageLength==1:
soup=fullPage(page)
print soup
else:
print title
print "Page Id = ",pageId
print page.summary
print "Page Link = ",url
#print "References : ",references

pass



#if __name__=="__main__":
# wiki()