Is there a way to return the length of the results from the following line?
import wikipedia
query = input("What do you want to lookup? ")
wikipedia.search(query)
Thanks!
I know that .search will return the first ten results, and that you can specify more or less, but I'd like to be able to tell how many results there are. I couldn't find this in this documentation, although I may not be looking in the right place. Any help is appreciated! https://wikipedia.readthedocs.io/en/latest/code.html#api
It seems that the
wikipediapackage doesn't provide an API for the total number of hits. MediaWiki itself, however, does have such an option:srinfo=totalhits.Knowing this, getting the information from Wikipedia should be trivial (the documentation page linked above also has some code examples, Python included):