goldsmith / Wikipedia

A Pythonic wrapper for the Wikipedia API
https://wikipedia.readthedocs.org/
MIT License
2.88k stars 520 forks source link

wikipedia.exceptions.WikipediaException: An unknown error occured: "The "srsearch" parameter must be set." #185

Open jcfk opened 6 years ago

jcfk commented 6 years ago

This comes from a simple wikipedia.page(title) call. I do not have access to the particular title in question, unfortunately.

AlmasM commented 5 years ago

Hi,

I was executing for title page ".deb" ->wikipedia.page(".deb") and I got following exception (DisambiguationError) and 1 error. If I try to catch the exception, the error is still there.

Traceback (most recent call last):
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/src/wikipedia_api.py", line 52, in get_object
    self.articleObject = wikipedia.page(self.articleName, auto_suggest=True)
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/wikiEnv/lib/python3.7/site-packages/wikipedia/wikipedia.py", line 276, in page
    return WikipediaPage(title, redirect=redirect, preload=preload)
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/wikiEnv/lib/python3.7/site-packages/wikipedia/wikipedia.py", line 299, in __init__
    self.__load(redirect=redirect, preload=preload)
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/wikiEnv/lib/python3.7/site-packages/wikipedia/wikipedia.py", line 393, in __load
    raise DisambiguationError(getattr(self, 'title', page['title']), may_refer_to)
wikipedia.exceptions.DisambiguationError: "Deb" may refer to: 
Deb (surname)
Deb (given name)
débutante
Dynamic energy budget theory
Epidermolysis bullosa dystrophica
Digital Economy Act 2010
Digital Economy Act 2017
German Ice Hockey Federation
Diepoxybutane
New South Wales 900/800 class railcar
deb (file format)
Debrecen International Airport
Deb Shops
Deb (album)
Debs (disambiguation)
Debra (disambiguation)
Debbie (disambiguation)
Deborah (disambiguation)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/src/wikipedia_game.py", line 93, in <module>
    run_main()
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/src/wikipedia_game.py", line 86, in run_main
    answer = wikiAnswer.run_wikipedia_search(inputObject)
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/src/wikipedia_game.py", line 65, in run_wikipedia_search
    self.run_wiki_help(visited, inputObject.startPage)
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/src/wikipedia_game.py", line 39, in run_wiki_help
    self.run_wiki_help(visited, article)
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/src/wikipedia_game.py", line 39, in run_wiki_help
    self.run_wiki_help(visited, article)
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/src/wikipedia_game.py", line 39, in run_wiki_help
    self.run_wiki_help(visited, article)
  [Previous line repeated 6 more times]
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/src/wikipedia_game.py", line 37, in run_wiki_help
    for article in self.get_wiki_object(articleName):
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/src/wikipedia_game.py", line 15, in get_wiki_object
    articleObject.get_object()
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/src/wikipedia_api.py", line 65, in get_object
    self.articleObject = wikipedia.page(articleModified)
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/wikiEnv/lib/python3.7/site-packages/wikipedia/wikipedia.py", line 270, in page
    results, suggestion = search(title, results=1, suggestion=True)
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/wikiEnv/lib/python3.7/site-packages/wikipedia/util.py", line 28, in __call__
    ret = self._cache[key] = self.fn(*args, **kwargs)
  File "/Users/wikip/Documents/PyCharm/WikipediaGame/wikiEnv/lib/python3.7/site-packages/wikipedia/wikipedia.py", line 109, in search
    raise WikipediaException(raw_results['error']['info'])
wikipedia.exceptions.WikipediaException: An unknown error occured: "The "srsearch" parameter must be set.". Please report it on GitHub!
VikasPatelVkp commented 5 years ago

I also got the error when working with wikipedia module in visual studio please share solution

Exception has occurred: WikipediaException An unknown error occured: "The "srsearch" parameter must be set."

madeofstardust commented 5 years ago

Has anyone come up with solution? I've got the same error

LSaldyt commented 4 years ago

This still seems to be active

Gurkiratsinghk commented 4 years ago

Try converting your query in string format. results = wikipedia.summary(f'{query}', sentences=5 ) I converted my query in string format and now it is working properly

kayode0x commented 4 years ago

NameError: name 'query' is not defined

bansaladi commented 4 years ago

> NameError: name 'query' is not defined

Try using this: elif 'wikipedia' in query: speak("Searching") query = ("wikipedia","") result = wikipedia.summary(f'{query}', sentences=2) print(result) speak(result)

instead of def

pujoseno commented 4 years ago

> NameError: name 'query' is not defined

Try using this: elif 'wikipedia' in query: speak("Searching") query = ("wikipedia","") result = wikipedia.summary(f'{query}', sentences=2) print(result) speak(result)

instead of def

yeah but i got still error

rk-poddar commented 2 years ago

I have also faced this problem. How do I fix it.

yefhieu commented 1 year ago

wikipedia.exceptions.WikipediaException: An unknown error occured: "The "srsearch" parameter must be set.". Please report it on GitHub!

I am facing the same error too

Niagawan-mave commented 1 year ago

An unknown error occured: "The "srsearch" parameter must be set.". Please report it on GitHub! I am also facing the same issues

Any solution ?

Niagawan-mave commented 1 year ago

I have found the problem, this error come out is because that in wikipedia.search(keyword), the keyword is null, that why the error say the parameter need to be set. So we just need to ensure that the parameter passed to the function is not null example if(len(keyword>0): ..... your coding result = wikipedia.search(keyword)

rubyazz commented 1 year ago

I have found the problem, this error come out is because that in wikipedia.search(keyword), the keyword is null, that why the error say the parameter need to be set. So we just need to ensure that the parameter passed to the function is not null example if(len(keyword>0): ..... your coding result = wikipedia.search(keyword)

i did it but i got still error