Wikipedia
Wikipedia copied to clipboard
The "srsearch" parameter must be set.
wikipedia.exceptions.WikipediaException: An unknown error occured: "The "srsearch" parameter must be set.". Please report it on GitHub!
I received the same issue when using the wikipedia.page() method. I filled the parameter for the page method with a query/suggestion from the search for a Japanese film (Nekeddo burâddo: Megyaku) using wikipedia.search(). I didn't extensively test why the error occured as it was easier for me to remove this film from my list....however:
Wikipedia does not return any results or suggestions for this title. Google however, does direct to a page with the English title of this film.
I suspect the error is coming from what was passed to the wikipedia.page() method.
I found this issue every-time whenever I created tkinter application using wikipedia
I found the same error. i am trying to use wikipedia using tkinter application. For both wikipedia,page() and wikipedia.summary() it showing the same error.
I found the same error... please share solution
I has the same issue with react. You get this error because searching is being done with "". Here how I solved it:
const Search = () => {
const [term, setTerm] = useState("setDefaultSearchTerm");
const [results, setResults] = useState([]);
useEffect(() => {
const search = async () => {
const results = await axios.get("https://en.wikipedia.org/w/api.php", {
params: {
action: "query",
list: "search",
origin: "*",
format: "json",
srsearch: term ,
},
});
setResults(results.data.query.search);
};
// this is when first time we rerender the component
if (term && !results.length) {
search();
} else {
const timeoutId = setTimeout(() => {
if (term) {
search();
}
}, 500);
return () => {
clearTimeout(timeoutId);
};
}
}, [term]);
const renderedResults =
results.length > 0 &&
results.map((result) => {
return (
<div key={result.pageid} className="result">
<div className="content">
<div className="header">{result.title}</div>
{result.snippet}
</div>
</div>
);
});
return (
<div>
<input
value={term}
onChange={(e) => setTerm(e.target.value)}
className="input"
type="text"
/>
<div className="results">{renderedResults}</div>
</div>
);
};
export default Search;
I found the error ocurrs when I try to summary ''. I just skip the'',and the problem can be solved! the mistake : wikipedia.summary("", sentences=1)
I also got this error in tkinter
Solution => You may have added brackets while calling a function, ex. btn = Button(app, text="Button", command=function).pack()
If you wish to search a string on wikipedia, and it has an assigned variable 'query': wikipedia.summary([query], sentences=1) Use '[ ] ' brackets.