Question: Python Programing Hello. I'm having a problem with my programming assignment. I'm trying to use Python library called Wikipedia its wrapper for Wikipedia API. When
Python Programing
Hello.
I'm having a problem with my programming assignment. I'm trying to use Python library called Wikipedia its wrapper for Wikipedia API. When I run code it executes the first part of it then I'm getting page errors:
.
Here is the code part:
import wikipedia
print ("1: Searching Wikipedia for 'Lexus'") try: print (wikipedia.page('Lexus')) print ('-' * 60) except wikipedia.exceptions.DisambiguationError as e: print (str(e)) print ('+' * 60) print ('DisambiguationError: The page name is ambiguous') print
print ("2: Searching Wikipedia for 'Lexus (company)'") print (wikipedia.page('Lexus_(company)')) print
result = wikipedia.page('Lexus_(company)').content.encode('UTF8') print ("3: Result of searching Wikipedia for 'Lexus_(company)':") print (result) print
orange_count = result.count('lexus') print
print ("The Wikipedia page for 'Lexus_(company)' has " + \ "{} occurrences of the word 'Lexus'".format(lexus_count)) print
1: Searching Wikipedia for Lexus kwikipediaPage Lexus 2 Searching Wikipedia for Lexus company) Traceback most recent call last) D: College Python Labs lab 3 kaminski lab3 p2.py in module 15 print pedia for 16 print (wikipedia.page 17 print D:\Program Files Anaconda3 liblsite-packages wrikipedia wikipedia. py in page if there is no suggestion or search results, the page doesn't exist raise Page Error (title) 275 276 return wikipediaPage(title, redirect redirect preload preload) 277 elif pageid is not None 278 return wikipediaPage(pageid pageid, preload preload) \Program Files\Anaconda3 libAsite-packages wikipedia aikipedia.py in init raise Value Error 297 298 299 self load (redirect redirect preload preload) 303 301 if preload D: Program Files\Anaconda3 liblsite-packages wikipedia Wikipedia.py in load in Page 343 iff has attr(self, 344 345 raise Page Error (self-title) else 346 raise PageError(pageid self. pageid) Page id lexus company does not match any pages Try another id In [49] 1: Searching Wikipedia for Lexus kwikipediaPage Lexus 2 Searching Wikipedia for Lexus company) Traceback most recent call last) D: College Python Labs lab 3 kaminski lab3 p2.py in module 15 print pedia for 16 print (wikipedia.page 17 print D:\Program Files Anaconda3 liblsite-packages wrikipedia wikipedia. py in page if there is no suggestion or search results, the page doesn't exist raise Page Error (title) 275 276 return wikipediaPage(title, redirect redirect preload preload) 277 elif pageid is not None 278 return wikipediaPage(pageid pageid, preload preload) \Program Files\Anaconda3 libAsite-packages wikipedia aikipedia.py in init raise Value Error 297 298 299 self load (redirect redirect preload preload) 303 301 if preload D: Program Files\Anaconda3 liblsite-packages wikipedia Wikipedia.py in load in Page 343 iff has attr(self, 344 345 raise Page Error (self-title) else 346 raise PageError(pageid self. pageid) Page id lexus company does not match any pages Try another id In [49]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
